invoke-expression problem
$com10 = "cmd /c miis_staged_run step 10"
$com11 = "cmd /c miis_staged_run step 11"
invoke-expression $com10
invoke-expression $com11
i have expected first expression have completed before going on second expression. on occasion (especially if takes long time on 30 minutes) $com11 start running before $com10 has finished. there way ensure first 1 finishes before starting second one? if matters, miis_staged_run .net program.
thanks -- dean
the code below wil fire cmd.exe , notepad.exe. notepad.exe childprocess of cmd.exe. code below continue if both notepad , cmd.exe have finished.
$process = new-object system.diagnostics.process
$si = new-object system.diagnostics.processstartinfo
$si.filename = "cmd.exe"
$si.arguments = "/k start notepad.exe"
$process.startinfo = $si
$process.start()
$processid = $process.id
$process.waitforexit()
while (get-wmiobject win32_process -filter "parentprocessid = $processid")
{
sleep -seconds 1
}
Windows Server > Windows PowerShell
Comments
Post a Comment