Thursday, March 31, 2011

Create a desktop URL shortcut from command line

        set WshShell = WScript.CreateObject("WScript.Shell")
        set strDesktop = WshShell.SpecialFolders("Desktop")
         set oUrlLink = WshShell.CreateShortcut(strDesktop & "\MicrosoftLink.lnk")
         oUrlLink.TargetPath = ""

Save the above text in a .vbs file (use notepad) and call the vbs file from command prompt.

To create a shortcut to an exe instead of a web page, check this out

1 comment:

  1. 1 question, what if i need the script to first check if the url shortcut already exists or not on desktop? and in case of positive then create none, and case negative, create such shortcut-...??

    any idea, will help.



Comments will appear once they have been approved by the moderator