2

I want to write a powershell script that opens unique instances of the same program, with input arguments to it. But my problem is when I use the example code below - the xml-file is opened in the same program window. Not in unique windows.

So, first example. When I execute the following code I get four instances of the program opened.

start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe"
Start-Sleep -Seconds 10

start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" 
Start-Sleep -Seconds 10

start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" 
Start-Sleep -Seconds 10

start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe"

All good so far.

I can also open the program with xml-file input and by that starting a script. This is done with this code:

start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" "D:\laserkartor\18A003\open.xml"

Still all is fine.

But when I run the following code, with the attempt to open four separate windows/instances and running the four different scripts in parallel - they are opened in the same window instead of four different windows.

$proc1 = start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" "D:\laserkartor\18A003\open.xml" -PassThru
Start-Sleep -Seconds 10

$proc2 = start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" "D:\laserkartor\18A005\open.xml" -PassThru
Start-Sleep -Seconds 10

$proc3 = start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" "D:\laserkartor\18A031\open.xml" -PassThru
Start-Sleep -Seconds 10

$proc4 = start-process "C:\Program Files\OCAD\OCAD 2018 Mapping Solution\OCAD 2018 Mapping Solution_64bit.exe" "D:\laserkartor\18B029\open.xml" -PassThru
Start-Sleep -Seconds 10

Any idea of how I can solve this?

StefanK
  • 31
  • 1
  • 3
    It looks like logic to reuse an existing instance when a file argument is given is built into the `OCAD 2018 Mapping Solution_64bit.exe` executable. Unless it also supports a command-line parameter to explicitly request a new instance, `Start-Process` won't be able to help you. – mklement0 Jan 02 '23 at 19:41

0 Answers0