Powershell run exe with args with return code and wait for completion

One of my big tasks is writing software packaging scripts.  I find them quite easy in batch files and vbs but have not been successful in powershell.  Specifically I'd like to:

  • run an exe
  • with args
  • with return code
  • waiting for completion. 
  • do so in version 2.0 as desktops won't generally have 3.0 installed. 
  • However including echoargs.exe or the like along with the files would be acceptable.   

I've found many postings on how to do each separate item but haven't found the right combination to provide all actions at once. Here's an example script.

msiexec.exe /qn /i somefile.msi /l*v somelog.log

Has anyone figured this out?



June 25th, 2015 1:37pm

Has anyone figured what out, specifically?

This article may be helpful:

Windows IT Pro: Running Executables in PowerShell

Free Windows Admin Tool Kit Click here and download it now
June 25th, 2015 1:46pm

First off native PowerShell V2 is obsolete and went out of service with WS2003 and XP.

All EXEs can easily run in PowerShell exactly as they do in a callsic batch but you can do much more when in PowerShell.

All batch files can be run from PowerShell if needed.

I recommend taking the course on PowerShell or getting a beginners book to learn how it works.  This would not take much of your time.

The following is not a script:

msiexec.exe /qn /i somefile.msi /l*v somelog.log

It is just a command line. Run it at a PowerShell prompt exactly as it is and it will work exactly as it always does.

June 25th, 2015 2:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics