2013-07-25 29 views
5

Tôi hiện đang viết một tập lệnh có liên quan đến một số cài đặt gỡ cài đặt trên thiết bị WES 7. Một trong những ứng dụng tôi cần phải gỡ cài đặt (VMware Horizon View Client) yêu cầu khởi động lại. Khi đây là một phần của tập lệnh, có vẻ như chấp nhận nút mặc định (YES) và tiến hành khởi động lại thiết bị. Do đó, tập lệnh không thành công.Powershell Uninstall Script - Có một nhức đầu thực

Tôi thực sự đánh giá cao sự trợ giúp của bạn về cách ngăn việc khởi động lại này diễn ra.

FYI: Tập lệnh này được gửi xuống qua công cụ quản lý và được chạy theo cách nâng cao trên mục tiêu.

Đây là kịch bản của tôi:

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 

tôi sẽ rất nhiều đánh giá cao một số giúp đỡ trong việc làm thế nào để ngăn chặn sự khởi động lại một nửa thông qua kịch bản.

Trả lời

10

Tôi đề nghị KHÔNG sử dụng Win32_Product. Mỗi lần Win32_Product được gọi là nó kiểm tra tính nhất quán phần mềm của mỗi lần cài đặt. Điều này không chỉ làm cho mọi thứ rất chậm, nó cũng có thể kích hoạt một phần mềm sửa chữa nếu nó tìm thấy một cái gì đó sai.

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

Thay vì đi vào sổ đăng ký và chỉ cần gọi chuỗi gỡ cài đặt.

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

Bạn có thể sử dụng lá cờ norestart msiexec để cố gắng ngăn chặn khởi động lại.

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

Các vấn đề liên quan