How can I find the Upgrade Code for an installed MSI file?

MSI Upgrade Code Retrieval (via PowerShell / WMI) UPDATE: HTML Export VBScript – screenshot section 2 here. Uninstalling?: Uninstall via Upgrade or Productcode, Via Product Name, etc… The PowerShell script below should retrieve all related product codes, upgrade codes and product names installed on your machine (table output). Screenshot of output (full script below): These … Read more

Detecting USB drive insertion and removal using windows service and c#

You can use WMI, it is easy and it works a lot better than WndProc solution with services. Here is a simple example: using System.Management; ManagementEventWatcher watcher = new ManagementEventWatcher(); WqlEventQuery query = new WqlEventQuery(“SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2”); watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); watcher.Query = query; watcher.Start(); watcher.WaitForNextEvent();

Generating a unique machine id

I had the same problem and after a little research I decided the best would be to read MachineGuid in registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography, as @Agnus suggested. It is generated during OS installation and won’t change unless you make another fresh OS install. Depending on the OS version it may contain the network adapter MAC address … Read more

What Library for Powershell 6 contains the get-wmiobject command?

Gert Jan Kraaijeveld’s helpful answer offers a solution for cmdlets that truly are available only in Windows PowerShell (not also in PowerShell [Core] 6+). In this particular case, however, as Lee_Daily notes in a comment, you can use the Get-CimInstance cmdlet, which is available in PowerShell [Core] 6+ too: Get-CimInstance CIM_Product | Select-Object Name, PackageCache … Read more