0

I'm trying to script a repair/reinstallation of an application, but Microsoft documentation is not very detailed on this subject: https://msdn.microsoft.com/en-us/library/aa393044(v=vs.85).aspx

$_.Reinstall(10) is using InstallMode "package" but what does it include and do? It doesn't seem to reinstall shortcuts ($_.Reinstall(9)). Do I really need to run the method several times? Does anybody know where I can find more detailed documentation of the Win32_Product-methods?

What do the Configure-method do, and how do i work it? https://msdn.microsoft.com/en-us/library/aa389278(v=vs.85).aspx

Jeroen Mostert
  • 27,176
  • 2
  • 52
  • 85
Dfox
  • 1
  • 1
  • These methods are just wrappers around the native Windows Installer functions. That documentation has [a bit more details](https://msdn.microsoft.com/library/windows/desktop/aa370375). Not much more, but a bit. – Jeroen Mostert Oct 25 '16 at 11:34
  • That is good enough for me. The rest I'll figure out by testing. Thanks! :) – Dfox Oct 25 '16 at 12:17
  • [Avoid using `Win32_Product`](https://stackoverflow.com/questions/71575378/powershell-for-software-inventory/71576041#71576041). In your case, it would be better to consult vendor documentation and learn how to perform a repair/modify install of their software so you don't trigger the problems inherent with the use of `Win32_Product`. – codewario Mar 24 '22 at 14:30

1 Answers1

0

Most (if not all) of these are just shims to call native APIs, as Jeroen says. So basically:

MsiReinstallProduct is not a "reinstall", it's a repair. You'd only call it if the product was actually broken in some way (or you want to check it). The parameters say what you want to repair. I don't know why it wouldn't repair shortcuts except for the obvious reason that they were not installed by the original MSI in the first place. The WMI call seems strange to me considering that the native API uses a bit mask of everything you want to repair, and but WMI's Reinstall seems to take a single number, so maybe you do need to call it multiple times.

Configure is MsiConfigureProduct, and I've never found a good use for this except for uninstalling where you configure the product to be absent.

Heath Stewart did a lot of work exposing MSI to PowerShell, that may be more useful:

https://github.com/heaths/psmsi

You can set logging policy while you run your tests and look at the msixxx.log files in the temp folder - there may be some clue as to what's going on, such as making sure you've got the right product, what Windows thinks it's repairing etc. It doesn't seem to me that the WMI classes are very helpful here, which is why Heath's interfaces my be much better at this.

PhilDW
  • 20,260
  • 1
  • 18
  • 28