Run Malwarebytes in a batch script!

Paul Black

I WANT TO BELIEVE!
Guru
VIP
Local time
9:35 AM
Messages
3,823
Location
Planet Earth VGhlIFgtRmlsZXM=
Good evening,

I am trying to run Malwarebytes [v3.5.1.2522] that was downloaded to the default location in a batch script running in Vista 32-bit but without much success at the moment!

I am basically trying to run a quick scan in silent mode. This is what I have tried [among many other variations]...

Code:
C:\PROGRA~1\Malwarebytes\Anti-Malware\mbam.exe /quickscan-silent

Do I need to use something like...

Code:
C:\PROGRA~1\Malwarebytes\Anti-Malware\mbamapi /scan -quick -silent -remove

Has anyone got any ideas please?

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
Well, after scouring the Internet this doesn't appear to be possible! :banghead: Oh well, it was worth asking!
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
I have a folder on the desktop that I am unable to open in a batch file.

The properties when clicked on the desktop say that it is a folder.
When double-clicked it opens in explorer as a folder under desktop.
When the properties are clicked there it shows as...

File (.{aanaannn-nann-nnna-nnna-nnnnnnnnnnna})

Numbers and characters replaced with alpha [a] and numeric [n] letters.

When the icon it is double-clicked on the desktop it opens fine!

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
UPDATE:

Not to worry, I forgot that is was a shell file and that I needed to do something different/specisl for it!
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
I wonder if anyone can help with this please!

I have a test computer that I use and often save shortcuts/icons/files [anything really] to the desktop.
I have setup a .bat file that I always leave open from which I can run each the following:

01. chkdsk.
02. sfc.
03. Extended Disk Cleanup.
Malwarebytes [N/A].
05. CCleaner.
06. Empty Recycle Bin.
07. Defragment.
08. Revo Uninstaller.
09. System Specifications.
10. Quit Program.
11. Sleep.
12. Restart.
13. Shutdown.

Using a batch script [that I can incorporate into my .bat file as a menu option], I want to delete everything [shortcuts/icons/files] off of the desktop except the .bat file itself and one folder.

Would it be something like this to leave the .bat file:

Code:
for %%i in (%userprofile%\desktop\*.*) do if not "%%i"=="MyBatFile.bat" del /q "%%i"

Has anyone got any ideas please?

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
Hi Paul,

you don't say what %%i is or where it is from. I understand what it isn't from your example, and I made this command: dir *.* /b /s | find /v "MyBatFile.bat". Remeber that FIND is case sensitive in what it finds.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 x64, Vista x64, 8.1 smartphone
CPU
Intel E8400 65W 64-bit
Motherboard
Gigabyte EP45-UD3LR
Memory
DDR2 2 x 2GB, 1GB x 2
Graphics Card(s)
XFX Radeon HD5750
Sound Card
AMD High Definition Audio; Realtek High Definition Audio
Monitor(s) Displays
iiyama prolite X2377HDS
Screen Resolution
1920 x 1080
Hard Drives
500GB 7200 rpm Seagate ST3500413AS 16MB, 500GB 5400 rpm Toshiba MQ02ABF050H 32MB, 200GB 7200 rpm Seagate ST3200820AS 8MB, 2TB 7200 rpm Western Digital WD20EZRX 64MB
PSU
Enermax Liberty Modular
Case
Antec P193 Midi Tower
Keyboard
Mionix ZIBAL 60
Mouse
Razer USB 2.0 Diamondback Mouse or Huion Graphics Tablet
Browser
Internet Explorer, Lunascape, Firefox, Opera, Avast Safezone
Thanks for the reply iko22.

You don't say what %%i is or where it is from. I understand what it isn't from your example, and I made this command: dir *.* /b /s | find /v "MyBatFile.bat". Remeber that FIND is case sensitive in what it finds.

The %%i is the loop variable.

The code you posted lists files.

I want to delete everything [shortcuts/icons/files] off of the desktop except the .bat file itself and one folder.

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
Hello Paul

The code I posted lists files except the .bat file. I was unable to test the del command on my computer.

You might have to run something like this:
dir *.* /b /s | find /v "MyBatFile.bat" > output.txt
type output.txt | find /v "subdirectory_name" > out2.txt
del < out2.txt

But like I say, I cannot test the syntax of this batch on my computer.
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 7 x64, Vista x64, 8.1 smartphone
CPU
Intel E8400 65W 64-bit
Motherboard
Gigabyte EP45-UD3LR
Memory
DDR2 2 x 2GB, 1GB x 2
Graphics Card(s)
XFX Radeon HD5750
Sound Card
AMD High Definition Audio; Realtek High Definition Audio
Monitor(s) Displays
iiyama prolite X2377HDS
Screen Resolution
1920 x 1080
Hard Drives
500GB 7200 rpm Seagate ST3500413AS 16MB, 500GB 5400 rpm Toshiba MQ02ABF050H 32MB, 200GB 7200 rpm Seagate ST3200820AS 8MB, 2TB 7200 rpm Western Digital WD20EZRX 64MB
PSU
Enermax Liberty Modular
Case
Antec P193 Midi Tower
Keyboard
Mionix ZIBAL 60
Mouse
Razer USB 2.0 Diamondback Mouse or Huion Graphics Tablet
Browser
Internet Explorer, Lunascape, Firefox, Opera, Avast Safezone
Once again, thanks for the reply iko22.

The code I posted lists files except the .bat file.

I appreciate that.

Seeing it is only the desktop that I am interested in I used the code:

Code:
C:\Users\MyUserName\Desktop .* /b /s | find /v "=="MyBatFile.bat"

The .* is correct above in the code, and obviously C:\Users\MyUserName\ will be replaced in the batch script with %userprofile%/.

The thing is, the list of the other files [not including "MyBatFile.bat"] includes the single folder, which I don't want deleted, and some C:\Users\MyUserName\AppData\Roaming|Mozilla\Firefox files, which is strange because I don't have Firefox on the desktop so it must be a hidden system file!

It also doesn't include the shortcuts/icons which I also want deleted.

Obviously the desktop.ini files don't show up in the list.

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
It also doesn't include the shortcuts/icons which I also want deleted.

That is odd. The .ink files do not show up in the output of a DIR command. I'd not noticed that before. You still can delete the shortcuts with del *.ink. So you would add another line to the batch file, saying del *.ink.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 x64, Vista x64, 8.1 smartphone
CPU
Intel E8400 65W 64-bit
Motherboard
Gigabyte EP45-UD3LR
Memory
DDR2 2 x 2GB, 1GB x 2
Graphics Card(s)
XFX Radeon HD5750
Sound Card
AMD High Definition Audio; Realtek High Definition Audio
Monitor(s) Displays
iiyama prolite X2377HDS
Screen Resolution
1920 x 1080
Hard Drives
500GB 7200 rpm Seagate ST3500413AS 16MB, 500GB 5400 rpm Toshiba MQ02ABF050H 32MB, 200GB 7200 rpm Seagate ST3200820AS 8MB, 2TB 7200 rpm Western Digital WD20EZRX 64MB
PSU
Enermax Liberty Modular
Case
Antec P193 Midi Tower
Keyboard
Mionix ZIBAL 60
Mouse
Razer USB 2.0 Diamondback Mouse or Huion Graphics Tablet
Browser
Internet Explorer, Lunascape, Firefox, Opera, Avast Safezone
Pah! I meant del *.lnk didn't I?

If a shortcut is not showing up in %userprofile%\desktop, then had you looked in \Public\Public Desktop\*.lnk?

----EDIT-------------

Here you are Paul. Ive completed the Bat file to search specified directory for files. The output of the Directory search is placed on the input of the FIND command, which finds all strings except one labelled "MyBatFile". The output of this command is redirected to a text file called output.txt. TYPE output.txt is then used to go through each file listing. The output from this command is output to another FIND command. This FIND command finds all listings except the directory name. The results are then redirected to out2.txt. TYPE Out2.txt is then the command to be processed in a FOR loop. The variable of the FOR loop is used to specify what file name is to be deleted. After these commands have been executed, a final command is used to DEL all .lnk shortcuts from the Public Desktop folder.

Code:
dir %USERPROFILE%\desktop\*.* /b /s | find /v "MyBatchFile.bat" > output.txt
type output.txt | find /v "single folder" > out2.txt
REM type out2.txt
REM pause
FOR /f %%G IN ('TYPE out2.txt') DO del /P %%G
REM pause
del /P "c:\Users\Public Desktop\*.lnk"
REM pause

Hope that Helps!!
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 7 x64, Vista x64, 8.1 smartphone
CPU
Intel E8400 65W 64-bit
Motherboard
Gigabyte EP45-UD3LR
Memory
DDR2 2 x 2GB, 1GB x 2
Graphics Card(s)
XFX Radeon HD5750
Sound Card
AMD High Definition Audio; Realtek High Definition Audio
Monitor(s) Displays
iiyama prolite X2377HDS
Screen Resolution
1920 x 1080
Hard Drives
500GB 7200 rpm Seagate ST3500413AS 16MB, 500GB 5400 rpm Toshiba MQ02ABF050H 32MB, 200GB 7200 rpm Seagate ST3200820AS 8MB, 2TB 7200 rpm Western Digital WD20EZRX 64MB
PSU
Enermax Liberty Modular
Case
Antec P193 Midi Tower
Keyboard
Mionix ZIBAL 60
Mouse
Razer USB 2.0 Diamondback Mouse or Huion Graphics Tablet
Browser
Internet Explorer, Lunascape, Firefox, Opera, Avast Safezone
Back
Top