CreateShortcut.ps1

This Script uses the WSHShell object to create a shortcut on the users desktop. For this example A shortcut to notepad.exe is created with no additional arguments. The path for the users desktop is retrieved from the environment settings.

#***************************************************************************
#** Script: CreateShortcut.ps1
#** Version: 1.0
#** Created: 12/19/2010 10:09AM
#** Author: Adriaan Westra
#** Website: http://www.westphil.nl
#**
#** Purpose / Comments:
#** Create a shortcut on the desktop
#**
#**
#** Changelog :
#** 12/19/2010 10:09AM : Initial version
#**
#***************************************************************************
# Clear the screen
Clear-Host
# Create Wscript.Shell object
$WS = New-Object -comObject WScript.Shell
# Get the path to the Users desktop
$DesktopPath = [Environment]::GetFolderPath(“Desktop”)
# Create the Shortcut on the desktop
$ShortCut = $WS.CreateShortCut($DesktopPath + “\Notepad.lnk”)
# Set the Program to be started with the shortcut
$ShortCut.TargetPath = “notepad.exe”
# Provide any arguments to the program
$ShortCut.Arguments = “”
# Set a keyboard combination for the shortcut
$ShortCut.HotKey = “ALT+CTRL+N”
# Save the changes to the shortcut
$ShortCut.Save()

Geef een reactie