簡體   English   中英

Powershell卸載腳本 - 真的很頭疼

[英]Powershell Uninstall Script - Have a real headache

我目前正在編寫一個腳本,其中包含許多安裝在WES 7設備上的程序卸載。 我需要卸載的其中一個應用程序(VMware Horizo​​n View Client)要求重新啟動。 如果這是腳本的一部分,它似乎接受默認按鈕(是)並繼續重啟設備。 因此腳本失敗了。

我非常感謝您幫助我們如何防止重啟。

僅供參考:此腳本通過管理工具發送,並在目標上以提升的方式運行。

這是我的腳本:

set-executionpolicy unrestricted
#############################################################
# Un-install unwanted applications
#############################################################
$application = Get-WMIObject Win32_Product -filter "Name='ThinPrint Client Windows 8.6'"
$application.Uninstall()
$application = Get-WMIObject Win32_Product -filter "Name='2X Client'"
$application.Uninstall()
$application = Get-WMIObject Win32_Product -filter "Name='Adobe Reader X (10.1.4)'"
$application.Uninstall()
$application = Get-WMIObject Win32_Product -filter "Name='VMware Horizon View Client'"
$application.Uninstall()
$application = Get-WMIObject Win32_Product -filter "Name='VERDE VDI User Tools'"
$application.Uninstall()
$application = Get-WMIObject Win32_Product -filter "Name='vWorkspace Connector for Windows'"
$application.Uninstall()

#############################################################
# Remove Internet Explorer Access
#############################################################
dism /online /norestart /Disable-Feature /FeatureName:Internet-Explorer-Optional-x86

#############################################################
# Remove IE Browser LNK from Taskbar
#############################################################
del "C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Launch Internet Explorer Browser.lnk"

#############################################################
# Make Citrix Receiver the shell
#############################################################
Push-Location
CD 'HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon'
New-Itemproperty -path .\ -name Shell -Type String -Value 'c:\program files\Citrix\Receiver\receiver.exe'
Pop-Location

set-executionpolicy restricted
# End of Script

我非常感謝如何防止重啟一半的腳本。

我強烈建議不要使用Win32_Product。 每次調用Win32_Product時,它都會對每個安裝進行軟件一致性檢查。 這不僅會使事情變得非常緩慢,而且如果發現錯誤也可能觸發軟件修復。

http://gregramsey.net/2012/02/20/win32_product-is-evil/

而是進入注冊表,只需調用卸載字符串。

http://support.microsoft.com/kb/247501

您可以使用msiexec的norestart標志來嘗試防止重新啟動。

http://msdn.microsoft.com/en-us/library/windows/desktop/aa372024(v=vs.85).aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM