Link to home
Start Free TrialLog in
Avatar of education-dynamics
education-dynamicsFlag for United States of America

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("WScript.Shell")
oShell.Run "runas /noprofile /user:ofy\rollout ""\\server\netlogon\Panda\Uninstall\removepanda.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
Avatar of Shift-3
Shift-3
Flag of United States of America image

It would be easier just to run the batch script through the group policy node Computer Configuration\Windows Settings\Scripts\Startup.  

Unlike logon scripts, startup scripts run under the local SYSTEM account, and thus have administrative privileges.
Avatar of education-dynamics

ASKER

Wow. I read a couple of different forums that said otherwise. Cripes! I will try it without the VB script and post back.
Avatar of RobSampson
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.
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
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.
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

Open in new window

Although, just thinking, that might still show a GUI if AVTC.exe or PAVAGENT.exe has one....so this might work instead.

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

Open in new window

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
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
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.
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
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have added the vbscript again. I will test over the next 2 days and post back.
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.