![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Is there an equivalent of the DOS shell "start /wait" in PowerShel Is there an equivalent of the DOS shell "start /wait", to allow a command, especially a GUI exe, to finish before executing the next line in the PowerShell.? -- Regards, Brillig. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Is there an equivalent of the DOS shell "start /wait" in PowerShel "Brillig" <Brillig@discussions.microsoft.com> wrote in message news:3942BB91-78A4-4074-9DFB-C02D2A2A7E9A@microsoft.com... > Is there an equivalent of the DOS shell "start /wait", to allow a command, > especially a GUI exe, to finish before executing the next line in the > PowerShell.? Specific example? |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Is there an equivalent of the DOS shell "start /wait" in PowerShel "Brillig" wrote: > Is there an equivalent of the DOS shell "start /wait", to allow a command, > especially a GUI exe, to finish before executing the next line in the The easiest way to implement is to use a .NET class, System.Diagnostics.Process to start a process and wait until the process is done. The following illustrates how it can be done.(simpliest case without using "System.Diagnostics.ProcessStartInfo" to pass process information) # get a handle for the Notepad process to wait for $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) # wait indefinitely... $notepad.WaitForExit() Now the powershell will hang after "$notepad.WaitForExit()" until you exit notepad.. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Is there an equivalent of the DOS shell "start /wait" in PowerShel > Now the powershell will hang after "$notepad.WaitForExit()" until you exit > notepad.. but not HAS too : PoSH> $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) PoSH> $notepad.WaitForExit MemberType : Method OverloadDefinitions : {System.Boolean WaitForExit(Int32 milliseconds), System.Void WaitForExit()} TypeNameOfValue : System.Management.Automation.PSMethod Value : System.Boolean WaitForExit(Int32 milliseconds), System.Void WaitForExit() Name : WaitForExit IsInstance : True PoSH> $notepad.WaitForExit(2000) FalsePoSH> $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) PoSH> $notepad.WaitForExit MemberType : Method OverloadDefinitions : {System.Boolean WaitForExit(Int32 milliseconds), System.Void WaitForExit()} TypeNameOfValue : System.Management.Automation.PSMethod Value : System.Boolean WaitForExit(Int32 milliseconds), System.Void WaitForExit() Name : WaitForExit IsInstance : True PoSH> $notepad.WaitForExit(2000) False more nice : PoSH> if ( $notepad.WaitForExit(2000) ) { >> "Notepad did quit in 2 seconds"} Else { >> "Notepad did NOT quit in 2 seconds"} >> Notepad did NOT quit in 2 seconds PoSH> if ( $notepad.WaitForExit(10000) ) { >> "Notepad did quit in 10 seconds"} Else { >> "Notepad did NOT quit in 10 seconds"} >> Notepad did quit in 10 seconds more nice : PoSH> $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) PoSH> if ( $notepad.WaitForExit(10000) ) { >> "running for $( (get-date) - $notepad.StartTime )" >> } >> running for 00:00:30.9150135 Greetings /\/\o\/\/ "Sung M Kim" <SungMKim@discussions.microsoft.com> wrote in message news:7DE68DEA-D22A-4B36-9805-A1E4D4BADB4F@microsoft.com... > "Brillig" wrote: > >> Is there an equivalent of the DOS shell "start /wait", to allow a >> command, >> especially a GUI exe, to finish before executing the next line in the > The easiest way to implement is to use a .NET class, > System.Diagnostics.Process to start a process and wait until the process > is > done. > > The following illustrates how it can be done.(simpliest case without using > "System.Diagnostics.ProcessStartInfo" to pass process information) > > # get a handle for the Notepad process to wait for > $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) > # wait indefinitely... > $notepad.WaitForExit() > > Now the powershell will hang after "$notepad.WaitForExit()" until you exit > notepad.. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Is there an equivalent of the DOS shell "start /wait" in PowerShel "Brillig" <Brillig@discussions.microsoft.com> wrote in message news:3942BB91-78A4-4074-9DFB-C02D2A2A7E9A@microsoft.com... > Is there an equivalent of the DOS shell "start /wait", to allow a command, > especially a GUI exe, to finish before executing the next line in the > PowerShell.? The PowerShell Community Extensions snapin has a Start-Process cmdlet that is aliased to "start" and "saps". It has a parameter that allows you to specify a wait (either indefinite or one that times out). -- Keith http://www.codeplex.com/powershellcx |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Is there an equivalent of the DOS shell "start /wait" in PowerShel old habbits ;-) "Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in message news:%23Lu4Z2aOHHA.4848@TK2MSFTNGP04.phx.gbl... > "Brillig" <Brillig@discussions.microsoft.com> wrote in message > news:3942BB91-78A4-4074-9DFB-C02D2A2A7E9A@microsoft.com... >> Is there an equivalent of the DOS shell "start /wait", to allow a >> command, >> especially a GUI exe, to finish before executing the next line in the >> PowerShell.? > > The PowerShell Community Extensions snapin has a Start-Process cmdlet that > is aliased to "start" and "saps". It has a parameter that allows you to > specify a wait (either indefinite or one that times out). > > -- > Keith > > http://www.codeplex.com/powershellcx > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Is there an equivalent of the DOS shell "start /wait" in PowerShel take a look at "Managing Processes in PowerShell" from Bruce Payette http://blogs.msdn.com/powershell/arc...owershell.aspx -- $hay http://scriptolog.blogspot.com "Sung M Kim" <SungMKim@discussions.microsoft.com> wrote in message news:7DE68DEA-D22A-4B36-9805-A1E4D4BADB4F@microsoft.com... > "Brillig" wrote: > >> Is there an equivalent of the DOS shell "start /wait", to allow a >> command, >> especially a GUI exe, to finish before executing the next line in the > The easiest way to implement is to use a .NET class, > System.Diagnostics.Process to start a process and wait until the process > is > done. > > The following illustrates how it can be done.(simpliest case without using > "System.Diagnostics.ProcessStartInfo" to pass process information) > > # get a handle for the Notepad process to wait for > $notepad = [System.Diagnostics.Process]::Start( "notepad.exe" ) > # wait indefinitely... > $notepad.WaitForExit() > > Now the powershell will hang after "$notepad.WaitForExit()" until you exit > notepad.. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Stuck on the "Please wait for the group policy client" screen during startup | Vista performance & maintenance | |||
| Different behavior of "Get-Content -Wait" on Windows Server 2008 | PowerShell | |||
| Inserting a "Wait" in the middle of a phone number | Vista mail | |||
| Message "Wait while Windows configures..." when I launch applicati | Vista performance & maintenance | |||
| Vista Beta 2: Installation Hangs on "please wait" | Vista installation & setup | |||