Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Is there an equivalent of the DOS shell "start /wait" in PowerShel

Reply
 
Old 01-16-2007   #1 (permalink)
Brillig


 
 

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 SpecsSystem Spec
Old 01-16-2007   #2 (permalink)
Marco Shaw


 
 

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 SpecsSystem Spec
Old 01-16-2007   #3 (permalink)
Sung M Kim


 
 

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 SpecsSystem Spec
Old 01-16-2007   #4 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

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 SpecsSystem Spec
Old 01-16-2007   #5 (permalink)
Keith Hill [MVP]


 
 

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 SpecsSystem Spec
Old 01-16-2007   #6 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

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 SpecsSystem Spec
Old 01-20-2007   #7 (permalink)
$hay


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46