Created
December 14, 2018 21:36
-
-
Save adamfortuno/ff79c2d26ab6675242ef933e3505ed4d to your computer and use it in GitHub Desktop.
Launch a Process, Create an Event Waiting for it to Complete, and Do Something When the Event Fires
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Situation... | |
There is a DOS batch script named foo.bat in C:\temp\foo.bat. We want | |
******************************************************************************/ | |
$things-todo-when-batchfile-completes = { | |
new-item 'c:\temp\thinger-done.txt' | |
Get-EventSubscriber | Unregister-Event | |
} | |
$file_run = Start-Process -FilePath ".\thing.bat" -PassThru | |
$job = register-objectevent -InputObject $file_run ` | |
-eventname exited ` | |
-SourceIdentifier test ` | |
-Action $event_response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment