• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1568
  • Last Modified:

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
0
education-dynamics
Asked:
education-dynamics
  • 8
  • 5
1 Solution
 
Shift-3Commented:
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.
0
 
education-dynamicsAuthor Commented:
Wow. I read a couple of different forums that said otherwise. Cripes! I will try it without the VB script and post back.
0
 
RobSampsonCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
education-dynamicsAuthor Commented:
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
0
 
RobSampsonCommented:
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

0
 
RobSampsonCommented:
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

0
 
education-dynamicsAuthor Commented:
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
0
 
education-dynamicsAuthor Commented:
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
0
 
education-dynamicsAuthor Commented:
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.
0
 
education-dynamicsAuthor Commented:
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
0
 
RobSampsonCommented:
It's probably the START /WAIT that's showing the DOS box.  In VBS, this line would hide it

        objShell.Run """C:\Program Files\Panda Software\Panda Administrator 3\PavInst\AVTC\AVTC.exe"" -a:uninstall", 0, True


but as you say, that makes no use of RunAs at all, so why it's asking for the password is very strange?!!  The only way I know of hiding a DOS prompt is to wrap it in a VBS script....although I have seen some other third-party commands that run hidden DOS commands.

Can you try the VBS again, now that the batch file is working (even though you haven't changed it)?

Regards,

Rob.
0
 
education-dynamicsAuthor Commented:
I have added the vbscript again. I will test over the next 2 days and post back.
0
 
education-dynamicsAuthor Commented:
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!
0
 
RobSampsonCommented:
OK, good to hear.  A little odd about the replication....but at least it's working.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now