Search code examples
command-linewindows-installer

Windows batch file does not wait for commands to complete


I have a batch file, which exists as soon as start it (run as admin) and does not execute commands that are in it, but if I specify it at the command-line, it runs fine and executes all commands.

Here's what's in it:

start /wait msiexec /x SetupServices.msi /qn /l* "SetupServices.uninstall.log"

start /wait msiexec /i SetupServices.msi /qn /l* "SetupServices.install.log"

Solution

  • Coming back to this question I think the "correct way" to do it is via PowerShell

    Start-Process -Wait -FilePath msiexec -ArgumentList /i, "setup.msi", /qn, /l*v, "install.log"   
    

    Or just prefix it with PowerShell; to invoke directly from CMD

    PowerShell; Start-Process -Wait -FilePath msiexec -ArgumentList /i, "setup.msi", /qn, /l*v, "install.log"
    

    No hacks and no tricks :-)