使用PowerShell卸载ClickOnce应用程序?

时间:2011-09-14 07:55:44

标签: powershell clickonce wmi

是否可以使用Windows PowerShell卸载一次点击客户端应用程序?

Get-WmiObject Win32_Product -Filter“name ='xxxx'”

当我在上面使用时,单击一次应用程序不会显示。但它适用于其他应用程序。 (获取没有过滤器的所有内容也不包含单击一次应用程序。但它在添加/删除程序UI中可见。)

请帮忙。

提前致谢。

2 个答案:

答案 0 :(得分:4)

请阅读:

http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/51a44139-2477-4ebb-8567-9189063cf340/

评论后编辑:

$InstalledApplicationNotMSI = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall | foreach-object {Get-ItemProperty $_.PsPath}


$UninstallString = $InstalledApplicationNotMSI | ? { $_.displayname -eq "YourAppicationDisplayName" } | select uninstallstring


cmd /c $UninstallString.UninstallString

问题在于,这不是一种无声的不稳定。 你必须为sendkey()TAB + ENTER添加代码以使其静默。

答案 1 :(得分:1)

这是一个简单的PowerShell脚本,用于卸载ClickOnce应用程序(其中DisplayName =您的应用程序进程名称)并处理UI:

$InstalledApplicationNotMSI = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall | foreach-object {Get-ItemProperty $_.PsPath}
$UninstallString = $InstalledApplicationNotMSI | ? { $_.displayname -match "[your app process name]" } | select UninstallString 
$wshell = new-object -com wscript.shell
$selectedUninstallString = $UninstallString.UninstallString
$wshell.run("cmd /c $selectedUninstallString")
Start-Sleep 5
$wshell.sendkeys("`"OK`"~")
相关问题