rt3x.de NoPaste

Create an URL Shortcut

This is a nopaste service, powered by Flying Paste.

Author: Malte Bublitz
Language/File type: PowerShell

Description

Create an URL Shortcut using `WScript.Shell`

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function Create-URLShortcut {
	param(
		[Parameter(Mandatory=$true)]
		[String]
		$Url,
		[Parameter(Mandatory=$true)]
		[String]
		$LinkName
	)
	
	$wshShell = New-Object -ComObject "WScript.Shell"
	$urlShortcut = $wshShell.CreateShortcut(
		(Join-Path $PWD $LinkName)
	)
	$urlShortcut.TargetPath = $Url
	$urlShortcut.Save()
}