Solved: VBScript -> Create a Shortcut Within a Folder

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.
Joined
Aug 7, 2007
Messages
9,028
Code:
Set objShell = CreateObject("WScript.Shell")
[COLOR=Green]'strPath = Shell.SpecialFolders("Desktop")[/COLOR]
strPath = "C:\Documents and Settings\TheOutcaste\Desktop"
Set objLink = objShell.CreateShortcut(strPath & "\test.lnk")
objLink.Arguments = "[COLOR=DarkRed][B]""[/B][/COLOR]1 2 3[COLOR=DarkRed][B]""[/B][/COLOR]"
objLink.Description = "This Launches Notepad"
objLink.HotKey = "CTRL+ALT+SHIFT+X"
objLink.IconLocation = "Notepad.exe,0"
objLink.TargetPath = "C:\Windows\Notepad.exe"
objLink.WindowStyle = 3
objLink.WorkingDirectory = "C:\Windows"
objLink.Save
The location to save the shortcut can be spelled out, or you can use the Shell.SpecialFolders method shown on the commented line.
Target Path and Working Directory will be automatically quoted if needed.
If Arguments need to be quoted, use two double quotes: ""
Window Style:
1 - Normal - Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.
3 - Maximized - Activates the window and displays it as a maximized window.
7 - Minimized - Minimizes the window and activates the next top-level window.
Icon Location is the file path\name of the file containing the Icon, and the offset to the icon in the file, starting at 0 for the first icon.

This will overwrite any existing shortcut with the same name (test.lnk in this case) without warning.
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top