1

I have looked around and can't seem to make it work with the research I've done.

I'm going to create a GPO to apply to workstations that will uninstall Malwarebytes 2.0 and 3.0 from a given system. This will allow us to roll out the enterprise version.

What I have in my .bat file is this:

@echo off

cd "C:\Program Files (x86)\Malwarebytes Anti-malware\"
unins000.exe /verysilent /suppressmsgboxes /norestart

cd "C:\Program Files\Malwarebytes\Anti-Malware\"
unins000.exe /verysilent /suppressmsgboxes /norestart

However, I noticed that if one of the paths above doesn't exits (1 will always not exist) than it will pop up a command prompt with an error. I'd like no boxes to pop up at all if possible. I then tried to accomplish this with vbs with the error:

compilation error: Invalid character

This is that script:

Dim objShell
Set objShell = WScript.CreateObject( WScript.Shell )
Sub MalwareBytes()
On Error Resume Next
objShell.Run(%ProgramFiles%Malwarebytes Anti-malwareunins000.exe verysilent 
suppressmsgboxes norestart)

objShell.Run(%ProgramFiles(x86)%MalwarebytesAnti-Malwareunins000.exe
verysilent suppressmsgboxes norestart)
End Sub
Set objShell = Nothing
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328

1 Answers1

2

How about, y'know, checking if a path actually exists before trying to go there?

if exist "C:\Program Files (x86)\Malwarebytes Anti-malware" (
  cd "C:\Program Files (x86)\Malwarebytes Anti-malware"
  unins000.exe /verysilent /suppressmsgboxes /norestart
)

The reason why your VBScript doesn't work is because your syntax is invalid. You need double quotes around the argument to CreateObject() as well as the command strings. With nested double quotes in case of the latter, because you have paths with spaces in them. Not to mention that it would be cleaner to check if a path actually exists in VBScript too.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 1
    Thanks! I wasn't aware of the "If exist" just learning. Appreciate it! – Michael Clayton Mar 13 '17 at 21:54
  • Please mark this as "answered" if it answered your question. Please take the 2-minute [tour], that's where it points out how to do that (you click the gray check mark). :-) – T-Heron Mar 13 '17 at 23:54
  • 1
    Done, thanks T.Heron. This is the solution, just need to format better. :) Appreciate everyone's help and I look forward to being able to help others as I become an expert. – Michael Clayton Mar 14 '17 at 15:06