Translate

Thursday, March 31, 2011

How to create a desktop shortcut from command line


   Copy the bolded text below to note pad, customize it to your requirement  and save it with a .vbs extension.
(Customizing to your request means replacing AIM.lnk in the bolded text below with the name you want for your shortcut,  replacing the C:\AIM\AIMStart.exe  with the actual path of your exe file that the shortcut needs to invoke etc.)


        set WshShell = WScript.CreateObject("WScript.Shell")
         strDesktop = WshShell.SpecialFolders("Desktop")
         set oShellLink = WshShell.CreateShortcut(strDesktop & "\AIM.lnk")
         oShellLink.TargetPath ="C:\AIM\AIMStart.exe"
         oShellLink.WindowStyle = 1
         oShellLink.IconLocation = "C:\AIM\aim.ico, 0"
         oShellLink.Description = "AIM"
         oShellLink.WorkingDirectory = strDesktop
         oShellLink.Save


After you save the .vbs file,  you can either execute it by double clicking it or invoke it from the command prompt. It will create a shortcut on your desktop. You can also invoke the vbs file thru batch files.

To create a desktop shortcut to a webpage , thru command line, check this out
http://dotnetanalysis.blogspot.com/2011/03/command-line-to-create-desktop-web.html

1 comment:

Comments will appear once they have been approved by the moderator