Reputation: 14016
Following this issue, I want to uninstall all the National Instrument software. From here first enter the wmic
in CMD. Then using the command product get name
I get a bunch of software all starting with NI
:
NI Logos 19.0
NI Trace Engine
NI-MXDF 19.0.0f0 for 64 Bit Windows
WIF Core Dependencies Windows 19.0.0
NI-VISA USB Passport 19.0.0
NI-VISA SysAPI x64 support 19.0.0
NI Controller Driver 19.0 64-bit
NI ActiveX Container (64-bit)
Math Kernel Libraries
NI MXS 19.0.0
NI LabWindows/CVI 2019 Network Variable Library
NI-VISA GPIB Passport 19.0.0
NI LabWindows/CVI 2017 Low-Level Driver (Original)
NI-RPC 17.0.0f0 for Phar Lap ETS
NI LabWindows/CVI 2017 .NET Library (64-bit)
...
I can uninstall them individually by for example:
product where name="NI Logos 19.0" call uninstall
and then I have to select y
/Y
. Given there are a lot of these software which I have to uninstall, I was wondering how I can automatize this process. The steps should be something like this:
product get name
starting with NI
and make a list out of itproduct where name=list[i] call uninstall
with the default y
/Y
I would appreciate if you could help me with this issue. Thanks for your support in advance.
P.S. Powershell solutions are also ok. In fact, any other solution to uninstall all of these using any other way is OK for me.
Upvotes: 1
Views: 7472
Reputation: 38654
You should be able to use the Like
operator with wmic.
From cmd
WMIC Product Where "Name Like 'NI%'" Call Uninstall /NoInteractive
From a batch-file
WMIC Product Where "Name Like 'NI%%'" Call Uninstall /NoInteractive
No command line options are documented as available to to the Uninstall
call, so using /NoInteractive
is offered here more in hope than as a definitive solution to your stated prompt.
Upvotes: 3
Reputation: 18051
If the applications were installed from an MSI you could use the following PowerShell code. If some other installer was used, you could add the silent uninstall parameters to the $uninstallString
in the loop:
$productNames = @("^NI")
$uninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
foreach ($key in (Get-ChildItem $uninstallKeys))
{
foreach ($productName in $productNames)
{
$name = $key.GetValue("DisplayName")
if ($name -match $productName)
{
$uninstallString = $key.GetValue("UninstallString")
if ($uninstallString -match "^msiexec(\.| )")
{
$uninstallString = ($uninstallString -replace "/I{","/X{" -replace "/X{", '/X "{' -replace "}",'}"') + " /qn /norestart"
}
Write-Host "Removing '$name' using '$uninstallString'..."
& cmd.exe /C $uninstallString
}
}
}
Upvotes: 1