I need to execute 3 commands from a PowerShell script.
The commands look like:
change user /install
c:\mydir\mysetup.exe
change user /execute
I created a .cmd file (let’s say, mycmd.cmd) and I try to launch it from my .ps1 script but I am unable to find the right syntax. Based on what I see the following syntax should work:
& cmd.exe /c c:\mydir\mycmd.cmd
but it doesn’t…
Can anybody please help?
Can I send each single line from my .ps1 file and run it in a synchronous way?
Regards
marius
Many thanks for your answer.
I made a test but it looks like commands in a .ps1 file are executed asynchronously.
So, for example, the third command is executed without waiting for the second to complete.
If I create a .cmd file the commands are executed in synchronous way, that’s the reason because I considered creating and running a .cmd file.
How can I solve my issue?
Regards
Marius