Batch file to create Internet shortcut on desktop

Creating Shortcuts with Batch File

I've created a Batch file which calls on the following VB Script to be able to create a shortcut to my desktop:

VB Script [named createLink.vbs]:
Code: set objWSHShell = CreateObject["WScript.Shell"] set objFso = CreateObject["Scripting.FileSystemObject"] ' command line arguments ' TODO: error checking sShortcut = objWSHShell.ExpandEnvironmentStrings[WScript.Arguments.Item[0]] sTargetPath = objWSHShell.ExpandEnvironmentStrings[WScript.Arguments.Item[1]] sWorkingDirectory = objFso.GetAbsolutePathName[sShortcut] set objSC = objWSHShell.CreateShortcut[sShortcut] objSC.TargetPath = sTargetPath objSC.WorkingDirectory = sWorkingDirectory objSC.Save[/quote] Batch File Example [for Windows Notepad]:
Code: @Echo off cscript createLink.vbs "C:\Users\Administrator\Desktop\Notepad.lnk" "C:\Windows\System32\notepad.exe"[/quote] But after creating the shortcut using this method, I'm not able to assign a custom icon for the shortcut. I get the following error message when trying to do so:





Any help and ideas on what I need to put into the VB Script and/or Batch File to be able to do this would be greatly appreciated! *Big Grin


Also, I know that I can simply do this by going to Start Menu\All Programs\Accessories\ right-clicking on Notepad and selecting Send to\Desktop [create shortcut]. Easy enough for creating a single shortcut. But I need to create several multiple shortcuts and using this Batch/VBS method would really save me a lot of time in doing so.

Video liên quan

Chủ Đề