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.

1 Answer 1

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().

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.