Run multiple programs from Powershell script

Posted on 2009-12-20
Last Modified: 2012-06-27
I need to replace a VB script with a Powershell script. The script installs the components for Microsoft Office Communicator. For example,

' Install Communicator
call WSHShell.Run ("msiexec -i communicator.msi /qb! /norestart",1,True)

' Install Latest Communicator Patch
call WSHShell.Run ("msiexec -p communicator.msp /qb! /norestart",1,True)

I am trying to do the same with Powershell using:

# Install Communicator
Invoke-Expression -Command "msiexec -i communicator.msi /qb!"

# Install Latest Communicator Patch
Invoke-Expression -Command "msiexec -p communicator.msp /qb! /norestart"

The trouble is that the second program does not wait for the first program to finish. How can I force each program to wait until the previous program has finished?

Question by:APAGroup
    LVL 10

    Accepted Solution


    Author Closing Comment

    I had good success with the [diagnostics.process]::start("notepad.exe").WaitForExit() method.


    # Install Communicator
    [diagnostics.process]::start("msiexec.exe","-i communicator.msi /qb!").WaitForExit()

    # Install Latest Communicator Patch
    [diagnostics.process]::start("msiexec.exe","-p communicator.msp /qb! /norestart").WaitForExit()
    LVL 10

    Expert Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Synchronize a new Active Directory domain with an existing Office 365 tenant
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now