Windows Vista Forums

Script execution problem
  1. #1


    OlivierT Guest

    Script execution problem

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

  2. #2


    OlivierT Guest

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

  3. #3


    Chris Dent Guest

    Re: Script execution problem


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

  4. #4


    Justin Rich Guest

    Re: Scipt execution problem

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


    "OlivierT" <OlivierT@newsgroup> wrote in message
    news:E8699270-6CE9-4E7B-8C2C-8F705E445DF3@newsgroup

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

  5. #5


    Larry__Weiss Guest

    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" <OlivierT@newsgroup> wrote in message
    > news:E8699270-6CE9-4E7B-8C2C-8F705E445DF3@newsgroup

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

  6. #6


    Larry__Weiss Guest

    Re: Script execution problem

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

  7. #7


    Larry__Weiss Guest

    Re: Script execution problem

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

  8. #8


    Hans Dingemans Guest

    Re: Scipt execution problem

    >> 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" <lfw@newsgroup> schreef in bericht
    news:us4IRid9KHA.5476@newsgroup

    > 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" <OlivierT@newsgroup> wrote in message
    >> news:E8699270-6CE9-4E7B-8C2C-8F705E445DF3@newsgroup

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

  9. #9


    Hans Dingemans Guest

    Re: Scipt execution problem

    >> 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" <lfw@newsgroup> schreef in bericht
    news:us4IRid9KHA.5476@newsgroup

    > 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" <OlivierT@newsgroup> wrote in message
    >> news:E8699270-6CE9-4E7B-8C2C-8F705E445DF3@newsgroup

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

  10. #10


    OlivierT Guest

    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" <lfw@newsgroup> schreef in bericht
    > news:us4IRid9KHA.5476@newsgroup

    > > 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" <OlivierT@newsgroup> wrote in message
    > >> news:E8699270-6CE9-4E7B-8C2C-8F705E445DF3@newsgroup
    > >>> 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 System SpecsSystem Spec

Page 1 of 2 12 LastLast
Script execution problem problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
make the script wait for the execution of a program PedroCesar PowerShell 3 18 Dec 2009
Conditional execution of script for logged-on user Hemant VB Script 6 20 Jul 2009
Script Execution Over Network Justin R. VB Script 12 11 Jan 2009
Retaining variables after script execution Tim Munro PowerShell 2 25 Nov 2008
Terminate Script Execution? MKielman PowerShell 13 13 Oct 2006