1

To run a new, discrete instance of an application we have been manually creating a shortcut of the application .exe file and then editing the Target property of the shortcut to include a space and character(s) after the closing quote mark of the path, like this -

"C:\Program Files (x86)\Apps\MyApplication.exe" 2

When this shortcut is invoked it causes an entirely discrete instance of the application to run with it's own registry settings.

I want to automate the creation of the shortcut with a PowerShell script but using this -

$TargetFile = '"C:\Program Files (x86)\Apps\MyApplication.exe" 2'
$ShortcutFile = "C:\Users\USER1\Desktop\MyApplication.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = "C:\Program Files (x86)\Apps\MyApplication.exe"
$Shortcut.Save()

I find the Target property contains only the file path like this:

"C:\Program Files (x86)\Apps\MyApplication.exe"

without the appended 2.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
XMHell
  • 11
  • 2

1 Answers1

3

I am assuming that you want to pass parameter 2 along with the application.

You can try adding

$shortcut.Arguments = "2"

before the $Shortcut.Save().

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
ClumsyPuffin
  • 3,909
  • 1
  • 17
  • 17