Running a sequence install->uninstall->install for the same installer on a remote VM

MyHi 21 Reputation points

Hi, I wrote a python program that calls a Powershell script with popen. The Powershell script invokes a command on a remote windows virtual machine.
I have a sequence of commands installing a product, then uninstalling it, and when I want to install it it tells me that it is already installed. But if I put a sleep (5) between uninstall and the second install, it works perfectly. Everything runs on a windows virtual machine.
This sleep works for products that install / uninstall few files, but if I have larger products this sleep (5) is no longer useful. How can I make it wait until all the files are uninstalled so I can install it again? Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,171 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 42,826 Reputation points

    How does your PowerShell script launch the installer program? Does the script wait for the installer to complete before ending?

    0 comments No comments

  2. MyHi 21 Reputation points

    In Powershell script, I use Invoke-Command to launch the installer and I already set WaitForExit. And as I said, I install the product, all good. I uninstall it, and then I want to install it again, but it tells me that it is already installed, everything happening in a for loop. I have a list of commands. [Install installer1.exe, uninstall installer1.exe, install installer.exe, ....]

    0 comments No comments