Ojas Pednekar
Ojas Pednekar

Reputation: 269

Clarification of code to change target of a Shortcut(.lnk) file

I am a Java programmer, and I do not know anything about VBScript. I needed a way to modify the target path of a certain shortcut, and I according to my research, only VBScript can help me. I tried it, but there were many errors.


I tried to resolve them by a butt ton of googling, but I think there is some other problem. Here is the code:

Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Users\pedne\Desktop\Zoom.lnk")
shortcut.TargetPath = "C:\Users\pedne\AppData\Roaming\Zoom\bin\Zoom.exe ""--url=zoommtg\://zoom.us/join?action=join&confno=955 1234 1234&pwd=12345"""
shortcut.Save

I do not know whether I need any prerequisites or external libraries for writing VBScript code, and I wrote it on notepad.I would also like to know whether there is any 100% Java or any other workaround to this. (Totally up to you) Please excuse me if I do not understand anything about your answers as I copied the code from Change a shortcut's target from command prompt


The last error I got was at Line 3 char 1, Invalid procedure or call

Upvotes: 0

Views: 683

Answers (1)

41686d6564
41686d6564

Reputation: 19641

Do not append the arguments to the target path. Use the Arguments property instead:

shortcut.TargetPath = "C:\Users\pedne\AppData\Roaming\Zoom\bin\Zoom.exe"
shortcut.Arguments = "--url=zoommtg\://zoom.us/join?action=join&confno=955 1234 1234&pwd=12345"
shortcut.Save

Upvotes: 2

Related Questions