views:

106

answers:

1

I have a powershell script which executes from a c# call (ex.. Process.Start(powershell.exe file.ps1);)

notepad.exe filename

this however seems to block script completion, as the event of completion is not fired until the notepad dialog is closed.

Is there a way for me to start notepad.exe but let the script complete execution. Maybe a powershell thing I missed. Preferably it would be something that allows the rest of file.ps1 to be blocking while just that line is async.

A: 

If you can use PowerShell 2.0, then go for background jobs (PsJob).

A PsJob runs a command or expression asynchronously and "in the background" without interacting with the console. The command prompt returns immediately and you can query for the job results at your convenience. You can run background jobs on a local or remote computer.

Also, check this:

http://stackoverflow.com/questions/1392192/is-it-possible-to-call-powershell-cmdlets-asynchronously

Andrei Drynov
Can't switch to 2.0. This is for a production environment.
maxfridbe