andrew
2005-11-07 12:31:02 UTC
Hi
I need a script that will create a shortcut with the target path relative to
the folder where the script is run. I have the following script which
creates a shortcut using absolute paths:-
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = "MyFile.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = "C:\Folder1\LocationOfScript\SubFolder\MyFile.exe"
oLink.Description = "Shortcut to MyFile.exe"
oLink.IconLocation = "C:\Folder1\LocationOfScript\SubFolder\MyFile.exe"
oLink.Save
What I actually want to be able to do is to replace
"C:\Folder1\LocationOfScript" with ".", but this then creates a target path
of "C:\SubFolder\MyFile.exe" instead of the full path. How can I get this to
create the shortcut with a target path of
"Drive:\NewFolderStructure\LocationOfScript\SubFolder\MyFile.exe" from with
whatever directory the script is run?
Thanks for your help
Andrew
I need a script that will create a shortcut with the target path relative to
the folder where the script is run. I have the following script which
creates a shortcut using absolute paths:-
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = "MyFile.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = "C:\Folder1\LocationOfScript\SubFolder\MyFile.exe"
oLink.Description = "Shortcut to MyFile.exe"
oLink.IconLocation = "C:\Folder1\LocationOfScript\SubFolder\MyFile.exe"
oLink.Save
What I actually want to be able to do is to replace
"C:\Folder1\LocationOfScript" with ".", but this then creates a target path
of "C:\SubFolder\MyFile.exe" instead of the full path. How can I get this to
create the shortcut with a target path of
"Drive:\NewFolderStructure\LocationOfScript\SubFolder\MyFile.exe" from with
whatever directory the script is run?
Thanks for your help
Andrew