8

Sorry if this has been asked before but I can't find a relevant answer

I want to create a shortcut on a users desktop and fill in the Start In value on in.

I can create the Icon but how do I make powershell fill in the Start in value

$TargetFile = "C:\Program Files (x86)\Program"
$ShortcutFile = "$env:Public\Desktop\Shorcut.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()
5
  • 1
    Probably obvious if you run $Shortcut | Get-Member. Commented Sep 4, 2017 at 13:56
  • These are the options I get: Load Save Arguments Description FullName Hotkey IconLocation RelativePath TargetPath WindowStyle WorkingDirectory What should I use Commented Sep 4, 2017 at 14:09
  • WorkingDirectory Commented Sep 4, 2017 at 14:19
  • 4
    When in doubt, read the documentation. Commented Sep 4, 2017 at 14:26
  • Worked thanks so much for your help people Commented Sep 4, 2017 at 14:31

1 Answer 1

7

You can fill in the "Start in" value by simply adding this line:

$Shortcut.WorkingDirectory = "Path"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.