[SOLVED] Creating symlink from script on Windows 11
I'm trying to create a symlink for a duf file using the DzFile::link method.
I've created a 'XXX' folder in Scripts folder and tried to create a symlink pointing to the g8F head split DFormer using this code :
(function(){
var path = '%1/People/Genesis 8 Female/Developer Kit/Genesis 8 Female HeadSplit DFormer.duf'.arg(App.getDataFolderPathBase());
var file = new DzFile(path);
print(file.link('%1/Scripts/XXX/Genesis8Female.duf'.arg(App.getDataFolderPathBase())));
})();
The output is 'true' (successful) and I get a 'Genesis8Female.duf' file in my XXX folder.
However, this file is :
- a 'physical' one, not a symlink
- a binary one, unusable, of size 1.81 Ko (original is 135 Ko, uncompressed)
Post edited by Mike3D on

Comments
On Windows, this creates a Shell Link. You should use the file extension .lnk for this file. See also the Qt documentation for QFile.
Note, however, that despite the documentation for both DzFile and QFile stating that this will not overwrite an existing file but will instead return an error, this appears to not be the case. My testing shows it does overwrite the file and reports success.
Many thanks for your detailed answer @Omniflux
I should probably rely more on QT documentation, water is always clearer at its source !
Unfortunately I need a symlink and I will have to find an alternative for Windows users
Creating symlinks on Windows requires elevated privileges (See this Microsoft article)
You can do it if you are willing to click through a UAC prompt. See attached script.
You said symlink, but would a Daz JSON Link work for what you're doing? They have the advantage of referencing the original thumbnail and metadata.
Introduced in Daz Studio 4.9.4, they can be created via the UI, or through script - Script Sample
Many thanks for follow-up and pointing me to DazJSON Link, which is a great alternative to symlinks
Also many thanks for the script allowing to execute PowerShell commands.
I'm not sure that this is the best way to retrieve a DzAsset from its path, but this script works perfectly for my needs :
(function(){ var assetMgr = App.getAssetMgr(); // DzAssetMgr var path = 'People/Genesis 8 Female/Developer Kit/Genesis 8 Female HeadSplit DFormer.duf'; // Source file (relative path) var assets = assetMgr.findAssetsForFile(path, false, true); // [DzAssetHandle] if (assets.length < 1) return; var asset = new DzScriptHandle(assets[0]).object; // DzAsset var out = '%1/Scripts/XXX/Genesis8Female.duf.%3'.arg(App.getDataFolderPathBase()).arg(asset.getDSLinkExtension()); // Destination asset.saveDSLink(out); assetMgr.updateFolderBasedContainers(); // Refresh pane })();Argh ! Subsequent issue is that I can't execute the link (Unknown File Format) :
var uri = new DzUri('/Scripts/XXX/Genesis8Female.duf.djl'); App.getContentMgr().openUri(uri);Probably want to use App.getContentMgr().openFile() instead.
You're right, this time everything works as expected
Again, many thanks for awesome support !