Script execution problem

O

OlivierT

Hi all,

I'm trying to install patches in PowerShell script. I'm using
([WMICLASS]"\root\cimv2:win32_process").create("cmd.exe /K
`"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet /norestart`" ") to
install a patch.

It works well for 1 patch but when I want to installe more patches, it
failed becaus PowerShell lunch all CMD at the same time.

Is there a way to force PowerShell to wait a command finish befor execute
the next one ?

Thank you,
Olivier
 

My Computer

O

OlivierT

Scipt execution problem

Hi all,

Is it possible to execute command line by line ?
I need to execute the next line when the previous one is done. My objective
is to install patches but Windows Installer can execute only one instance at
a time.

Thank you,

Olivier
 

My Computer

C

Chris Dent

It's more of a problem with msiexec in that it returns immediately.

Perhaps try out Start-Process first and see if that waits for msiexec to
complete:

Start-Process -FilePath "c:\ ...." -ArgumentList "/quiet", "/norestart"
-Wait

Otherwise , You may consider creating a process watcher. i.e.

Function Start-MsiExec($Command)
{
While (Get-Process msiexec -ne $Null)
{
Write-Verbose "Waiting for running process to complete"
Start-Sleep 5
}
([WMICLASS]"\root\cimv2:win32_process").create($Command)
}

Start-MsiExec "cmd.exe /K `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu
/quiet /norestart`""
etc

Chris



OlivierT wrote:

> Hi all,
>
> I'm trying to install patches in PowerShell script. I'm using
> ([WMICLASS]"\root\cimv2:win32_process").create("cmd.exe /K
> `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet /norestart`" ") to
> install a patch.
>
> It works well for 1 patch but when I want to installe more patches, it
> failed becaus PowerShell lunch all CMD at the same time.
>
> Is there a way to force PowerShell to wait a command finish befor execute
> the next one ?
>
> Thank you,
> Olivier
>
 

My Computer

J

Justin Rich

Re: Scipt execution problem

by default thats how ps and the command line work... it wont execute unless
the previous is complete..


"OlivierT" <[email protected]> wrote in message
news:[email protected]

> Hi all,
>
> Is it possible to execute command line by line ?
> I need to execute the next line when the previous one is done. My
> objective
> is to install patches but Windows Installer can execute only one instance
> at
> a time.
>
> Thank you,
>
> Olivier
 

My Computer

L

Larry__Weiss

Re: Scipt execution problem

I think what was meant was that they wanted to insure that the
entire process associated with a command was complete before
allowing the next command to begin.

A PowerShell command like Invoke-Item or Start-Process
can begin activity that will overlap with the next command
unless some sort of check is available to stall the PowerShell
interpreter.

I can't readily tell from the original post how the user will
know when one patch is complete.

Maybe we need to see the PowerShell source code.

- Larry

On 5/17/2010 10:26 AM, Justin Rich wrote:

> by default thats how ps and the command line work... it wont execute
> unless the previous is complete..
>
>
> "OlivierT" <[email protected]> wrote in message
> news:[email protected]

>> Hi all,
>>
>> Is it possible to execute command line by line ?
>> I need to execute the next line when the previous one is done. My
>> objective
>> is to install patches but Windows Installer can execute only one
>> instance at
>> a time.
>>
>> Thank you,
>>
>> Olivier
>
 

My Computer

L

Larry__Weiss

Try this at a PowerShell prompt:

cmd.exe /c start /w "c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet
/norestart`" "

- Larry


On 5/17/2010 5:06 AM, OlivierT wrote:

> Hi all,
>
> I'm trying to install patches in PowerShell script. I'm using
> ([WMICLASS]"\root\cimv2:win32_process").create("cmd.exe /K
> `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet /norestart`" ") to
> install a patch.
>
> It works well for 1 patch but when I want to installe more patches, it
> failed becaus PowerShell lunch all CMD at the same time.
>
> Is there a way to force PowerShell to wait a command finish befor execute
> the next one ?
>
> Thank you,
> Olivier
 

My Computer

L

Larry__Weiss

I think now it should be

cmd.exe /c start /w "" "c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet
/norestart"

- Larry

On 5/17/2010 4:50 PM, Larry__Weiss wrote:

> Try this at a PowerShell prompt:
>
> cmd.exe /c start /w "c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet
> /norestart`" "
>
> - Larry
>
>
> On 5/17/2010 5:06 AM, OlivierT wrote:

>> Hi all,
>>
>> I'm trying to install patches in PowerShell script. I'm using
>> ([WMICLASS]"\root\cimv2:win32_process").create("cmd.exe /K
>> `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet /norestart`" ") to
>> install a patch.
>>
>> It works well for 1 patch but when I want to installe more patches, it
>> failed becaus PowerShell lunch all CMD at the same time.
>>
>> Is there a way to force PowerShell to wait a command finish befor execute
>> the next one ?
>>
>> Thank you,
>> Olivier
 

My Computer

H

Hans Dingemans

Re: Scipt execution problem

>> unless some sort of check is available to stall the PowerShell
PS> # Wait till Notepad exits...
PS> notepad | Out-Null
PS>
PS> # Or use -Wait parameter
PS> Start-Process notepad -Wait
PS>

HtH,
Hans

"Larry__Weiss" <[email protected]> schreef in bericht
news:[email protected]

> I think what was meant was that they wanted to insure that the
> entire process associated with a command was complete before
> allowing the next command to begin.
>
> A PowerShell command like Invoke-Item or Start-Process
> can begin activity that will overlap with the next command
> unless some sort of check is available to stall the PowerShell
> interpreter.
>
> I can't readily tell from the original post how the user will
> know when one patch is complete.
>
> Maybe we need to see the PowerShell source code.
>
> - Larry
>
> On 5/17/2010 10:26 AM, Justin Rich wrote:

>> by default thats how ps and the command line work... it wont execute
>> unless the previous is complete..
>>
>>
>> "OlivierT" <[email protected]> wrote in message
>> news:[email protected]

>>> Hi all,
>>>
>>> Is it possible to execute command line by line ?
>>> I need to execute the next line when the previous one is done. My
>>> objective
>>> is to install patches but Windows Installer can execute only one
>>> instance at
>>> a time.
>>>
>>> Thank you,
>>>
>>> Olivier
>>
 

My Computer

H

Hans Dingemans

Re: Scipt execution problem

>> unless some sort of check is available to stall the PowerShell
PS> # Wait till Notepad exits...
PS> notepad | Out-Null
PS>
PS> # Or use -Wait parameter
PS> Start-Process notepad -Wait
PS>

HtH,
Hans

"Larry__Weiss" <[email protected]> schreef in bericht
news:[email protected]

> I think what was meant was that they wanted to insure that the
> entire process associated with a command was complete before
> allowing the next command to begin.
>
> A PowerShell command like Invoke-Item or Start-Process
> can begin activity that will overlap with the next command
> unless some sort of check is available to stall the PowerShell
> interpreter.
>
> I can't readily tell from the original post how the user will
> know when one patch is complete.
>
> Maybe we need to see the PowerShell source code.
>
> - Larry
>
> On 5/17/2010 10:26 AM, Justin Rich wrote:

>> by default thats how ps and the command line work... it wont execute
>> unless the previous is complete..
>>
>>
>> "OlivierT" <[email protected]> wrote in message
>> news:[email protected]

>>> Hi all,
>>>
>>> Is it possible to execute command line by line ?
>>> I need to execute the next line when the previous one is done. My
>>> objective
>>> is to install patches but Windows Installer can execute only one
>>> instance at
>>> a time.
>>>
>>> Thank you,
>>>
>>> Olivier
>>
 

My Computer

O

OlivierT

Re: Scipt execution problem

Thank you. It was what I'm looking for

Olivier

"Hans Dingemans" wrote:

> >> unless some sort of check is available to stall the PowerShell
> >> interpreter.
>
> PS> # Wait till Notepad exits...
> PS> notepad | Out-Null
> PS>
> PS> # Or use -Wait parameter
> PS> Start-Process notepad -Wait
> PS>
>
> HtH,
> Hans
>
> "Larry__Weiss" <[email protected]> schreef in bericht
> news:[email protected]

> > I think what was meant was that they wanted to insure that the
> > entire process associated with a command was complete before
> > allowing the next command to begin.
> >
> > A PowerShell command like Invoke-Item or Start-Process
> > can begin activity that will overlap with the next command
> > unless some sort of check is available to stall the PowerShell
> > interpreter.
> >
> > I can't readily tell from the original post how the user will
> > know when one patch is complete.
> >
> > Maybe we need to see the PowerShell source code.
> >
> > - Larry
> >
> > On 5/17/2010 10:26 AM, Justin Rich wrote:

> >> by default thats how ps and the command line work... it wont execute
> >> unless the previous is complete..
> >>
> >>
> >> "OlivierT" <[email protected]> wrote in message
> >> news:[email protected]
> >>> Hi all,
> >>>
> >>> Is it possible to execute command line by line ?
> >>> I need to execute the next line when the previous one is done. My
> >>> objective
> >>> is to install patches but Windows Installer can execute only one
> >>> instance at
> >>> a time.
> >>>
> >>> Thank you,
> >>>
> >>> Olivier
> >>
> .
>
 

My Computer

O

OlivierT

It works ! Thank you !

Olivier

"Chris Dent" wrote:

>
> It's more of a problem with msiexec in that it returns immediately.
>
> Perhaps try out Start-Process first and see if that waits for msiexec to
> complete:
>
> Start-Process -FilePath "c:\ ...." -ArgumentList "/quiet", "/norestart"
> -Wait
>
> Otherwise , You may consider creating a process watcher. i.e.
>
> Function Start-MsiExec($Command)
> {
> While (Get-Process msiexec -ne $Null)
> {
> Write-Verbose "Waiting for running process to complete"
> Start-Sleep 5
> }
> ([WMICLASS]"\root\cimv2:win32_process").create($Command)
> }
>
> Start-MsiExec "cmd.exe /K `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu
> /quiet /norestart`""
> etc
>
> Chris
>
>
>
> OlivierT wrote:

> > Hi all,
> >
> > I'm trying to install patches in PowerShell script. I'm using
> > ([WMICLASS]"\root\cimv2:win32_process").create("cmd.exe /K
> > `"c:\Hot_Fix_W2K8\Windows6.1-KB974431-x64.msu /quiet /norestart`" ") to
> > install a patch.
> >
> > It works well for 1 patch but when I want to installe more patches, it
> > failed becaus PowerShell lunch all CMD at the same time.
> >
> > Is there a way to force PowerShell to wait a command finish befor execute
> > the next one ?
> >
> > Thank you,
> > Olivier
> >
> .
>
 

My Computer

Top