我可以在PowerShell中卸载NVIDIA图形驱动程序,但我无法弄清楚如何静默执行此操作。正常的代码如下:
一旦进程启动,它会显示 NVIDIA 卸载程序对话框 (NVIDIA Uninstaller dialog box),以手动选择/点击“卸载”按钮继续进行。我的 UninstallString 如下:
我尝试了以下几种方式,但似乎没有任何效果。
请指导我如何进行静默卸载。
#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
一旦进程启动,它会显示 NVIDIA 卸载程序对话框 (NVIDIA Uninstaller dialog box),以手动选择/点击“卸载”按钮继续进行。我的 UninstallString 如下:
"C:\Windows\SysWOW64\RunDll32.EXE" "C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL",UninstallPackage Display.Driver
我尝试了以下几种方式,但似乎没有任何效果。
Start-Process -FilePath "C:\Windows\SysWOW64\RunDll32.EXE" -ArgumentList "/X $argList /quiet" -Wait
Start-Process $filePath -ArgumentList $argList "/S" -Wait
请指导我如何进行静默卸载。
-silent
可以与cmd /c $un.UninstallString -silent -deviceinitiated
命令一起使用,而-deviceinitiated
则避免了重启。但在我的情况下,我需要使用Start-Process
命令,并且如果我像这样编写它Start-Process $filePath -ArgumentList $argList -Wait -silent
,则会返回错误。 - Ali Furqan-silent
应该作为 $argList 的一部分。它不是 PowerShellStart-Process
命令的有效参数。 - Theo$argList += '-silent', '-deviceinitiated'
就可以了。 - zett42$argList += ' -silent', '-deviceinitiated'
已经生效。非常感谢。 - Ali Furqan