使用powershell卸载一个exe软件
Uninstall a exe software using powershell
我正在关注 this thread 从我的 Windows 10 个系统中卸载 mozilla firefox。
我最初使用 exe 安装程序安装了 mozilla firefox,但没有执行 gwmi -Class Win32_Product
.
的 mozilla 条目
有什么方法可以在我的 windows 系统上触发该软件的卸载程序?
注意:我无法为此目的使用 msi 安装程序。
如果你运行
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ | ? { $_ -match "Firefox" }
它将 UninstallString
显示为:
C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe
您应该可以 运行 删除 Firefox。使用 /s
切换到 运行 静默卸载。
大致如下:
'"C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe /s"' | cmd
添加具有架构差异的修改后的工作代码
$x86App = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' | ? { $_ -match "Firefox" }
$x64App = Get-ChildItem 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | ? { $_ -match "Firefox" }
if ($x86App)
{
$UninstallPath = ($x86App |Get-ItemProperty).UninstallString
Start-Process -NoNewWindow -FilePath $UninstallPath -ArgumentList " /s"
}
elseif($x64App)
{
$UninstallPath = ($x64App |Get-ItemProperty).UninstallString
Start-Process -NoNewWindow -FilePath $UninstallPath -ArgumentList " /s"
}
我正在关注 this thread 从我的 Windows 10 个系统中卸载 mozilla firefox。
我最初使用 exe 安装程序安装了 mozilla firefox,但没有执行 gwmi -Class Win32_Product
.
有什么方法可以在我的 windows 系统上触发该软件的卸载程序?
注意:我无法为此目的使用 msi 安装程序。
如果你运行
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ | ? { $_ -match "Firefox" }
它将 UninstallString
显示为:
C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe
您应该可以 运行 删除 Firefox。使用 /s
切换到 运行 静默卸载。
大致如下:
'"C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe /s"' | cmd
添加具有架构差异的修改后的工作代码
$x86App = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' | ? { $_ -match "Firefox" }
$x64App = Get-ChildItem 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | ? { $_ -match "Firefox" }
if ($x86App)
{
$UninstallPath = ($x86App |Get-ItemProperty).UninstallString
Start-Process -NoNewWindow -FilePath $UninstallPath -ArgumentList " /s"
}
elseif($x64App)
{
$UninstallPath = ($x64App |Get-ItemProperty).UninstallString
Start-Process -NoNewWindow -FilePath $UninstallPath -ArgumentList " /s"
}