Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have been referring to answer number three of this post to write my PowerShell script, but it doesn't appear to be working.

$linkPath        = Join-Path ([Environment]::GetFolderPath("Desktop")) "My shortcut.lnk"
$targetPath      = Join-Path ([Environment]::GetFolderPath("MyDocuments")) "...\run.exe"
$link            = (New-Object -ComObject WScript.Shell).CreateShortcut($linkPath)
$link.TargetPath = $targetPath

## Added after grawity's post

It only prints out the code in the output pane but never seems to fully execute; no shortcut shows up on the desktop.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You need to call the Save method of the shortcut object to actually store the shortcut as a file.


See also:

share|improve this answer
Whoops, thank you for pointing that out! –  Rob Jan 1 '12 at 15:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.