Skip to content

Instantly share code, notes, and snippets.

@julenka
Created December 4, 2015 01:33
Show Gist options
  • Save julenka/c40aade62c8fd8d29d4b to your computer and use it in GitHub Desktop.
Save julenka/c40aade62c8fd8d29d4b to your computer and use it in GitHub Desktop.
MakeShortcut
if Wscript.Arguments.Count = 0 then
Wscript.Echo "Usage: make-shortcut.vbs shortcutName shortcutWorkingDir shortcutPath shortcutArgs..."
Wscript.Quit
end if
Dim shortcutName
Dim shortcutPath
Dim shortcutWorkingDir
Dim shortcutArgs
shortcutName = Wscript.Arguments(0)
shortcutWorkingDir = Wscript.Arguments(1)
shortcutPath = Wscript.Arguments(2)
For count = 3 To WScript.Arguments.Count-1
shortcutArguments = shortcutArguments & " " & Wscript.Arguments(count)
Next
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut(shortcutName)
shortcut.TargetPath = shortcutPath
shortcut.Arguments = shortcutArguments
shortcut.WorkingDirectory = shortcutWorkingDir
shortcut.Save
Wscript.Echo "Made shortcut " & shortcutName & " with target path " & shortcutPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment