# Solved: VBScript -> Create a Shortcut Within a Folder



## computerman29642 (Dec 4, 2007)

What is the simplest way to use VBScript to create a shortcut in a folder?


----------



## TheOutcaste (Aug 8, 2007)

```
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.


----------



## computerman29642 (Dec 4, 2007)

Thanks Outcaste.


----------

