Thank you for a very useful script, you saved my day 🙂
I would just add up few things if someone need it in the future.
I had to uninstall TrendMicro that asked for admin password, fight with UAC, and then install Kaspersky, all of those remotely, on our company domain.
So here is solution that I used:
- First, remote access, command prompt - sysinternals helped me, with following:
psexec.exe machine -s cmd.exe
For some reason, with -n and -p for user and password, even though I am domain admin, enterprise admin, local admin, below reg things gave me a access denied answer.
- Second, two lines below, will disable UAC (first) and not ask for it if you remoted as local admin (second)
reg.exe ADD HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem /v EnableLUA /t REG_DWORD /d 0 /f
reg.exe ADD HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
-Third, your script 🙂 Thanks again!
-Fourth, script that waits for process ntrmv.exe to end (not mine, found on net and adopted):
Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Dim strComputer, strProcess
strProcess = "ntrmv.exe"
strComputer = "computer"
Loop until ( IsProcessRunning( strComputer, strProcess ) = False )
Then I ran Silent kaspersky install.
All in all, for whole process I didn't need to force users to restart, all worked right after uninstall / install, I just did restart when they logged off at end of the day.