Create or edit a Windows Shortcut
Syntax objShell.CreateShortcut(strLinkFile) ShortcutObject.property = "Your Value" Key objShell A WScript.Shell object ShortcutObject An existing shortcut object
Optional sections in the VBscript below are commented out:
strLinkFile = "$env:Public\Desktop\MyShortcut.lnk" strTargetPath = "C:\demo\MyApp.exe" Set objShell = WScript.CreateObject("WScript.Shell") Set objLink = objShell.CreateShortcut(strLinkFile) objLink.TargetPath = $strTargetPath ' objLink.Arguments = "" ' objLink.Description = "MyProgram" ' objLink.HotKey = "ALT+CTRL+F" ' objLink.IconLocation = "%SystemRoot%\SystemResources\shell32.dll.mun, 94" ' objLink.WindowStyle = "1" ' objLink.WorkingDirectory = "C:\Program Files\MyApp" objLink.Save
Set objLink = Nothing
Run the VB script like this:
CSCRIPT C:\batch\makeshortcut.vbs
Internet Shortcuts
Unlike file/folder shortcuts, Internet Explorer/Edge Favourite (.URL) files are simple text files which you can create with a couple of ECHO statements. The favicons are stored as an Alternate Data Stream, though that is optional.
Echo [InternetShortcut] > demo.url
Echo URL=https://windevcluster.com/ >> demo.url
“Our life is frittered away by detail... simplify, simplify” ~ Henry David Thoreau
Arguments, display - WshArguments.Item
Function New-Shortcut - Function to create shortcut, with help and error handling.
Q263324 - Shortcut command truncates path names if the target does not currently exist.
PowerShell: New-Shortcut
Equivalent Windows CMD command: SHORTCUT - Create a windows shortcut (.LNK
file)