Home > other >  Silently Uninstall NVIDIA Display Driver using Uninstall String
Silently Uninstall NVIDIA Display Driver using Uninstall String

Time:08-21

I can uninstall NVIDIA Graphics Driver from PowerShell but I am unable to figure out how to do it silently. The normal code looks like this:

#Get Uninstall String from Registry
$us = Get-childItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" -ErrorAction SilentlyContinue | Get-ItemProperty | Where-Object {$_.DisplayName -like "*NVIDIA Graphics Driver*"} | select DisplayName, UninstallString

# Splitting the Uninstall String into executable and argument list
$unused, $filePath, $argList = $us.UninstallString -split '"', 3

# Any of the following command can start the process 
Start-Process -FilePath "C:\Windows\SysWOW64\RunDll32.EXE" -ArgumentList $argList -Wait
# or
Start-Process $filePath $argList -Wait

Once the process is started it displays the NVIDIA Uninstaller dialog box for manual selection/click of the UNINSTALL button to proceed further. My UninstallString looks like:

"C:\Windows\SysWOW64\RunDll32.EXE" "C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL",UninstallPackage Display.Driver

I have tried following ways but nothing seems to work.

Start-Process -FilePath "C:\Windows\SysWOW64\RunDll32.EXE" -ArgumentList "/X $argList /quiet" -Wait

Start-Process $filePath -ArgumentList $argList "/S" -Wait

Please guide me, how to do silent uninstallation.

CodePudding user response:

To summarize the comments into an answer:

#Get Uninstall String from Registry
$us = Get-childItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" -ErrorAction SilentlyContinue | Get-ItemProperty | Where-Object {$_.DisplayName -like "*NVIDIA Graphics Driver*"} | select DisplayName, UninstallString

# Splitting the Uninstall String into executable and argument list
$unused, $filePath, $argList = $us.UninstallString -split '"', 3

# Append arguments for silent uninstall
# -deviceinitiated avoids a system restart
$argList  = ' -silent -deviceinitiated'

# Any of the following command can start the process 
Start-Process -FilePath "C:\Windows\SysWOW64\RunDll32.EXE" -ArgumentList $argList -Wait

The key is to add any arguments intended for rundll32.exe to the $argList string.

  • Related