I am trying to create a shortcut link to pointing some target file.
I am able to put static target path but the problem is when I move the target file to some other place it's unable to open the target file cause target path don't have this file.
The scenario is like I am giving the user a zip folder which contains some files in different folders. A few folders may contain same files, to reduce size complications we are providing shortcut link files by targeting one source file.
But when user download the zip these link files pointing server files (due to static mapping) and user can't to open the server file.
This is how the zip folder structure
Extracted Folder ├─ PS1 Folder │ └─ Policy1 │ ├─ File1.txt │ │ └─ File2.txt.lnk │ ├─ Policy2 │ │ ├─ File1.txt.lnk │ │ └─ Temp.pdf │ └─ Policy3 │ ├─ Temp.pdf.lnk │ ├─ File2.txt │ └─ Test.pdf └─ PS2 Folder └─ Policy1 ├─ File3.txt └─ File2.txt.lnk
Here is our VBScript what I have used.
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Users\kumar\Desktop\shortcut\Network\Routersage\shortcutfile.lnk")
shortcut.TargetPath = "%windir%\system32\cmd.exe /c start """" ""%CD%\..\Network controls\F1.txt"""
shortcut.Save
I want my target target path should be like this
%windir%\system32\cmd.exe /c start "" "%CD%\..\Network controls\F1.txt"
Here what I am getting the error when I try with target path as I mentioned above code snippet.
I tried all Stack Overflow character escape solutions, but no use. Can anyone help me?
My ultimate goal is, my link file should be able to open target file where ever it's (that's server/client because I know the target file parent folder).