Invoke .exe as Foreground Process

wahlster
wahlster used Ask the Experts™
on
Hi, I am very new to Powershell.  I am trying to execute a backkup application in a try/catch block as a foreground process.  When I run the following commands in Powershell it appears to spawn the process as a background process and continues to next line of the script without waiting for the exe to complete.  I need the script to wait for the exe to complete.  Here is a snippit of the script:

    - Backup C: drive to H:\Backup
    $exe = 'C:\Program Files (x86)\Snapshot\snapshot.exe'
    & $exe C: H:\Backup

Thanks in advance for your help,
Terry

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
Use
  start-process 'C:\Program Files (x86)\Snapshot\snapshot.exe' -wait
instead. That waits until the process is terminated.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial