0

i am having a code shown below. When i execute this code i want start-Process should wait. Once it is executed i will be accessing th exit code through $process. But here it is not working properly.

$process=Start-Process  powershell -Verb runAs "$exePath ${args} "  #Run as administrator
 Write-Output "hello world"
 Write-Output $process.exitCode
Vipin
  • 938
  • 5
  • 18
  • 36
  • Possible duplicate of [How to tell PowerShell to wait for each command to end before starting the next?](https://stackoverflow.com/questions/1741490/how-to-tell-powershell-to-wait-for-each-command-to-end-before-starting-the-next) – Andrei Odegov May 31 '19 at 08:37
  • 2
    If you have problems with a command you should first look at its documentation and check the available options the command has. in this case you simply need "-wait -passthru" (docs: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-4.0) – D.J. May 31 '19 at 08:46
  • How to pass these arguments when we are using -Verb runas. If you see my example i am using Runas to execute elevated permission. Can you please suggest me with my example. – Vipin May 31 '19 at 09:48

0 Answers0