education-dynamics
asked on
VB script calls a batch file but does not execute
We are migrating from Panda AV to McAfee. I am trying to Uninstall Panda once McAfee is fully installed. I have created a VB script to run CMD as an admin account, which then calls a batch file since the executable requires admin rights. For some reason it is not working.
I know that the VB script runs from GPO because I can see the command windows open at startup prompting for credentials and then the VB script populates the credentials. However, the CMD window closes right after that and does not uninstall Panda. I have verified that the batch file itself works on its own if I run it manually. I have verified the admin credentials of account "rollout" as well.
I'm assuming there is something awry in the vbscript code or the handoff to the batch file, but maybe someone can tell me what is wrong with this scenario.
Here is the VBscript....
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScr ipt.Shell" )
oShell.Run "runas /noprofile /user:ofy\rollout ""\\server\netlogon\Panda\ Uninstall\ removepand a.bat"
WScript.Sleep 100
oShell.Sendkeys " ~"
Wscript.Quit
And here is the batch file....
@ECHO OFF
IF EXIST "C:\Program Files\McAfee\VirusScan Enterprise" (
GOTO REMOVEPANDA
) ELSE (
GOTO END
)
)
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT .exe" -a:uninstall
GOTO END
:END
Additional info...
Client machines are running XP Pro. Servers are running Server 2003
I know that the VB script runs from GPO because I can see the command windows open at startup prompting for credentials and then the VB script populates the credentials. However, the CMD window closes right after that and does not uninstall Panda. I have verified that the batch file itself works on its own if I run it manually. I have verified the admin credentials of account "rollout" as well.
I'm assuming there is something awry in the vbscript code or the handoff to the batch file, but maybe someone can tell me what is wrong with this scenario.
Here is the VBscript....
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScr
oShell.Run "runas /noprofile /user:ofy\rollout ""\\server\netlogon\Panda\
WScript.Sleep 100
oShell.Sendkeys " ~"
Wscript.Quit
And here is the batch file....
@ECHO OFF
IF EXIST "C:\Program Files\McAfee\VirusScan Enterprise" (
GOTO REMOVEPANDA
) ELSE (
GOTO END
)
)
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT
GOTO END
:END
Additional info...
Client machines are running XP Pro. Servers are running Server 2003
ASKER
Wow. I read a couple of different forums that said otherwise. Cripes! I will try it without the VB script and post back.
Shift-3 is right. StartUp scripts should be better, provided that no user interaction is required during the uninstall.
If you *need* to use your VBS file, it might be the SendKeys that is causing the issue. Is it more reliable to use something like PSExec, that passes the password directly, rather that using keystroke emulation.
See how you go.
Regards,
Rob.
If you *need* to use your VBS file, it might be the SendKeys that is causing the issue. Is it more reliable to use something like PSExec, that passes the password directly, rather that using keystroke emulation.
See how you go.
Regards,
Rob.
ASKER
So, I removed the vbscript from the computer startup GPO and replaced it with the batch file only. It runs, but there are two problems that remain.....
1. The command window still pops up asking for the user account password that I specified in the previous vbscript. How is this possible since it was removed and the batch file that I replaced it with starts running?
2. The batch file that runs the uninstallers still shows on the screen. I thought the -a was the switch to make it run silent, but maybe I need to add /s at the end? Like this.....
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall /S
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT .exe" -a:uninstall /S
1. The command window still pops up asking for the user account password that I specified in the previous vbscript. How is this possible since it was removed and the batch file that I replaced it with starts running?
2. The batch file that runs the uninstallers still shows on the screen. I thought the -a was the switch to make it run silent, but maybe I need to add /s at the end? Like this.....
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall /S
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT
Hmmm,
1. That's odd. Are you sure it's a computer StartUp script, not a user Login script? I'm not sure how it is still asking for the username and password, except that maybe the computer you're logging onto hasn't got the replicated Group Policy change yet. Try running "gpupdate /force", reboot and try again.
2. If you don't want the command prompt to appear on screen, try this VBS, *instead* of that batch:
Regards,
Rob.
1. That's odd. Are you sure it's a computer StartUp script, not a user Login script? I'm not sure how it is still asking for the username and password, except that maybe the computer you're logging onto hasn't got the replicated Group Policy change yet. Try running "gpupdate /force", reboot and try again.
2. If you don't want the command prompt to appear on screen, try this VBS, *instead* of that batch:
Regards,
Rob.
Set objShell = CreateObject("wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Program Files\McAfee\VirusScan Enterprise") Then
objShell.Run "cmd /c START """" /WAIT ""C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe"" -a:uninstall", 0, True
objShell.Run "cmd /c START """" /WAIT ""C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT.exe"" -a:uninstall", 0, True
End If
Although, just thinking, that might still show a GUI if AVTC.exe or PAVAGENT.exe has one....so this might work instead.
Rob.
Rob.
Set objShell = CreateObject("wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Program Files\McAfee\VirusScan Enterprise") Then
objShell.Run """C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe"" -a:uninstall", 0, True
objShell.Run """C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT.exe"" -a:uninstall", 0, True
End If
ASKER
RobSampson - I tried using your vbscript and it works, but it works just like the batch file. It prompts for the password and runs the script (even though I do not need to put in the password). I have attached a screenshot.
Untitled.png
Untitled.png
ASKER
I wonder if there are two separate problems here. Your vbscript does not call on the "runas" command, so why is it still prompting? I am sure I have taken that script out of my GPO. Confused...
Untitled2.png
Untitled2.png
ASKER
By the way....that removepanda_test.vbs is the one you asked me to try. I ran gpupdate on the machine I am trying this on before I restarted the computer.
ASKER
SO, it looks like my batch file is doing what I need it to do for the most part except for one thing - the command window still pops up and shows itself to the user. I need to turn this off somehow because I will get a flood of trouble tickets and phone calls from people freaking out. :O)
Any help in getting this accomplished would be appreciated.
Here is the batch file as it is running right now... I added the /q hoping it would run silent, but no joy. I have also tried /s and /silent.
@ECHO OFF
IF EXIST "C:\Program Files\McAfee\VirusScan Enterprise" (
GOTO CHECKPANDA
) ELSE (
GOTO END
)
)
:CHECKPANDA
IF EXIST "C:\Program Files\Panda Software\AVTC" (
GOTO REMOVEPANDA
) ELSE (
GOTO END
)
)
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall /q
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT .exe" -a:uninstall /q
GOTO END
:END
Any help in getting this accomplished would be appreciated.
Here is the batch file as it is running right now... I added the /q hoping it would run silent, but no joy. I have also tried /s and /silent.
@ECHO OFF
IF EXIST "C:\Program Files\McAfee\VirusScan Enterprise" (
GOTO CHECKPANDA
) ELSE (
GOTO END
)
)
:CHECKPANDA
IF EXIST "C:\Program Files\Panda Software\AVTC" (
GOTO REMOVEPANDA
) ELSE (
GOTO END
)
)
:REMOVEPANDA
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe" -a:uninstall /q
START "" /WAIT "C:\Program Files\Panda Software\Panda Administrator 3\PavInst\PLAgent\PAVAGENT
GOTO END
:END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have added the vbscript again. I will test over the next 2 days and post back.
ASKER
Thanks, Rob Sampson. It is working great now. I'm not sure why it took so long to replicate the change, but it looks like that's why it was still coming up with the RunAs vbscript. Thanks, again!
OK, good to hear. A little odd about the replication....but at least it's working. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
Unlike logon scripts, startup scripts run under the local SYSTEM account, and thus have administrative privileges.