0

I am looking to understand how (if possible) to change the "Start in" location of a particular executable shortcut using powershell. This shortcut, but default, lives on the desktop. The screenshot below shows the field I am looking to modify (this exists by right-clicking on the shortcut and selecting "Properties")

MATLAB Shortcut Properties

Does anyone know how to accomplish this with Powershell? I know I can run the executable from within Powershell and use the "-FilePath" argument (as described here: Starting an executable from a parent directory in PowerShell), but I am looking to modify the Desktop shortcut such that each time I open the executable from the desktop it will start in the specified folder.

Of course I could manually modify the desktop shortcut, but I am trying to automate this process.

Thank you in advance, Chris

EDIT: Thank you to @mklement0 for the link provided. Here is an example solution in case someone finds this post down the road:

$WScriptShell = New-Object -ComObject 'WScript.Shell'
$ShortcutFile = "$env:USERPROFILE\desktop\my_shortcut.lnk"
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.WorkingDirectory = 'c:\data'
$Shortcut.Save()
  • I hope [this answer](https://stackoverflow.com/a/47743337/45375) to the linked duplicate solves your problem; use the `.WorkingDirectory` property. – mklement0 Jul 26 '21 at 18:04

0 Answers0