I am currently writing a script that has involves a number of uninstalls of programs installed on a WES 7 device. One of the applications I need to uninstall (VMware Horizon View Client) asks for a restart. When this is part of the script, it seems to accept the default button (YES) and proceeds to reboot the device. The script therefore fails.
I would really appreciate your help in how to prevent this reboot from taking place.
FYI: This script is sent down via a management tool and is run in an elevated manner on the target.
This is my script:
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
I would very much appreciate some help in how to prevent the reboot half way through the script.
I strongly suggest NOT using Win32_Product. Every time Win32_Product is called it does a software consistency check of each installation. Not only does this make things very slow, it may also trigger a software repair if it finds something wrong.
http://gregramsey.net/2012/02/20/win32_product-is-evil/
Instead go into the registry and just call the uninstall string.
http://support.microsoft.com/kb/247501
You can use msiexec's norestart flag to try to prevent reboots.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa372024(v=vs.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With