使用PowerShell卸载ClickOne程序


如果你写了一个简单的程序,想让用户每次运行时都能自动检测更新,并且自动更新。此时可以考虑ClickOne部署,但是ClickOne应用程序安装后不是一个标准的MSI安装,所以用我们之前发的:使用PowerShell卸载软件 显然不适用。那如何用PowerShell卸载ClickOne程序?

注册表:HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall派上用场了。

Function Get-NonMSIApplication {
 $regPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall'
 Get-ChildItem $regPath  | foreach { 
 $product =  Get-ItemProperty $_.PSPath
 [PSCustomObject]@{DisplayName = $product.DisplayName;  UninstallString= $product.UninstallString}
 }
}

在我机器上运行后为:

PS> Get-NonMSIApplication
DisplayName        	UninstallString
-----------        	---------------
Virtual Lab Client 	rundll32.exe dfshim.dll,ShArpMaintain VirtualLabClientUI.application, Culture=neutral, PublicKeyT.
Microsoft OneDrive 	C:\Users\mosser\AppData\Local\Microsoft\SkyDrive\17.3.1173.0716\OneDriveSetup.exe  /uninstall

比如我想卸载OneDrive,可以使用:

$oneDrive = Get-NonMSIApplication | where { $_.DisplayName -eq 'Microsoft OneDrive' }
cmd /c $oneDrive.UninstallString
本文链接: https://www.pstips.net/uninstall-clickone.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

关于 Mooser Lee

我是一个Powershell的爱好者,创建了PowerShell中文博客,热衷于Powershell技术的搜集和分享。本站部分内容来源于互联网,不足之处敬请谅解,并欢迎您批评指正。

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注