Translate

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 = "http://www.microsoft.com"
         oUrlLink.Save



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
http://dotnetanalysis.blogspot.com/2011/03/create-shortcut-from-command-line.html

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.

    thanks.

    ReplyDelete

Comments will appear once they have been approved by the moderator