how to make a batch file work again

January 19, 2019 at 13:45:39
Specs: Windows 10, 4Gb
The batch whose code is below the double line used to toggle the Malwarebytes Service, but does so no longer. How can I get it to work again ?
=====================================================================

@ECHO OFF

REM Checking Service state
net start Malwarebytes Service 2>nul
if errorlevel 2 goto AlreadyRunning
if errorlevel 1 goto Error

REM Service started

GOTO ContinueWithBatch

:AlreadyRunning
REM Service is already running
net stop Malwarebytes Service
GOTO ContinueWithBatch

:Error
REM Service failed to start
GOTO ContinueWithBatch

:ContinueWithBatch

Basty


See More: how to make a batch file work again

Reply ↓  Report •

#1
January 19, 2019 at 14:20:06
run it as admin

if that doesnt work, try changing this line:

net start Malwarebytes Service 2>nul

with this:

net start MBAMService 2>nul

i5-6600K[delid]@4.7GHz/4.4GHz cahe/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz


Reply ↓  Report •

#2
January 19, 2019 at 14:30:25
Sad to say, that change caused NO improvement.

Basty


Reply ↓  Report •

#3
January 19, 2019 at 14:33:47
I have only minimal experience with batch files, and none at all
with "Malwarebytes Service" or "MBAMService", so I'm asking
a question more than I am suggesting a possible solution, but...

Is this run in the directory where the Malwarebytes executeable
is located, or does Windows know where it is so that you don't
have to specify a location?

-- Jeff, in Minneapolis


Reply ↓  Report •

Related Solutions

#4
January 19, 2019 at 14:49:39
The batch is NOT in the Mbam directory. But I CAN put it there - however, the batch deals with a SERVICE, not with the executable. When it used to work it was where it is now. I have tried running it from inside \Program Files\Malwarebytes\AntiMalware\ - NO improvement.

Basty


Reply ↓  Report •

#5
January 19, 2019 at 15:26:47
tested and all on my windows 10 machine:

@echo off
net start MBAMService >nul
if %errorlevel%==2 goto AlreadyRunning
goto ContinueWithBatch
:AlreadyRunning
REM Service is already running/no admin rights
net stop MBAMService
if %errorlevel%==2 echo Please Run as admin^!&pause&exit/b
:ContinueWithBatch
echo Succes^!
timeout 3 /NOBREAK

i5-6600K[delid]@4.7GHz/4.4GHz cahe/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz

message edited by hidde663


Reply ↓  Report •

#6
January 19, 2019 at 21:22:51
I copied and pasted your code into a Notepad file and saved it as 'service_toggle.bat' and it still did not work, so it seems that it is not the content of the bat which is inadequate, but the processing of the bat. I have not noticed any other of several bats failing, but it is the only one that deals with SERVICES. Perhaps SERVICES has put up some blockage.... ?

Basty


Reply ↓  Report •

#7
January 19, 2019 at 21:57:00

Reply ↓  Report •

#8
January 19, 2019 at 22:06:57
The status of the service did not toggle between 'running' and 'stopped'

Basty


Reply ↓  Report •

#9
January 19, 2019 at 22:29:01
An attempt to do it manually triggered "Windows could not start the Malwarebytes Service on Local Computer. Error 2: The system cannot find the file specified. " so I think I have to re-install Mbam.

Basty


Reply ↓  Report •

#10
January 19, 2019 at 23:45:24
I did uninstall, and installed the latest version. There was a problem with the Mbam service, so I redid that and this time there was no error message about the Mbam Service. The batch file still does not switch (toggle) Mbam. So I am at a loss.

Basty


Reply ↓  Report •

#11
January 20, 2019 at 02:16:50
I have discovered an alternate way to prevent Mbam from running at boot, so I no longer need that batch.

Basty


Reply ↓  Report •

#12
January 20, 2019 at 07:20:56
If Mbam's disappearing on you, you might have malware. Probably want to go that angle until ruled out.

How To Ask Questions The Smart Way


Reply ↓  Report •

#13
January 20, 2019 at 13:10:26
I assume you are trying to stop MBAM using the service when you are not using the program. This is how I went about it by starting it with a batch file:

=========================================================
:: Run from Admin shortcut.
sc config MBAMService start= auto
Start /MIN /W net start "Malwarebytes Service"
:: CHOICE /N /C YN /T 1 /D Y >NUL
Start /W "" "C:\Program Files\Malwarebytes\Anti-Malware\mbam.exe
Start /MIN /W net stop "Malwarebytes Service"
sc config MBAMService start= disabled

=========================================================

Closing MBAM stops the service. If you haven't already got CHOICE.EXE (for timing delay) in C:\Windows\System32 you can get it on the net or I can put it on an upload website.

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

#14
January 20, 2019 at 14:43:07
I want to use Mbam, but only SOMETIMES, not continuously. I mistakenly thought that stopping the Service was the only way to stop Mbam from launching with Windows. I have now found the setting that prevents it from launching with windows - so no longer need to mess with the Service.

Basty


Reply ↓  Report •

#15
January 20, 2019 at 17:06:35
Where is that setting? Maybe you have a later version than I have but my "malwarebytes free" service was running all the time, so I invented the above batch file (my #13) so that it only ran when I actually used MWB on demand.

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

#16
January 20, 2019 at 21:59:55
Mbam, Settings, Protection tab; at almost bottom of page : StartUp Options; toggle 'Start Malwarebytes at Windows StartUp'.


However, when I just accessed that to document the steps, I found it set ON; whereas I had set it OFF.
I think I took the Services Route when I previously discovered that auto-reverting ...

Basty


Reply ↓  Report •

#17
January 21, 2019 at 00:46:04
ill check with my aida64 for a hidden malware-bytes startup-routine when i get back home in about 9 hours.

Sorry to ask, but are you sure there isn't an entry under task-manager --> startup?

i5-6600K[delid]@4.7GHz/4.4GHz cache/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz


Reply ↓  Report •

#18
January 21, 2019 at 00:57:07
I have NO entry for Mbam in Task Manager's StartUps. I have rebooted the PC, and Mbam did not re-appear in the Systray.

Basty


Reply ↓  Report •

#19
January 21, 2019 at 09:31:51
Thanks for info at 16. Yep mine is there too but although MBAM doesn't start with Windows the service does. As I am only using the freebie then I decided not to have the service running for no reason whatsoever

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

#20
January 21, 2019 at 10:21:38
im using the free trial, which is expired :D

my script in #5 toggles it on or off

I cannot find anything, with aida64, no hidden startup entries i can find, altho i did find intel telemetry2, "product improvement".

i5-6600K[delid]@4.7GHz/4.4GHz cache/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz


Reply ↓  Report •

#21
January 21, 2019 at 12:47:48
I'm no longer concerned about the Service, now that I know how to prevent Mbam running in the background.

Had NO idea what aida64 is - so googled it - and may add it to my repertoire.

Basty


Reply ↓  Report •

#22
January 21, 2019 at 16:16:51
Because a file had disappeared, I uninstalled and re-installed Mbam, and so ended up with a trial Premium version - which I do NOT intend to buy. If I remember correctly once that expires, the option to set Mbam to NOT launch with Windows disappears, and then I may have to go the Service way again.

I had forgotten about Aida. I've tested the latest version, v5, - it seem powerful, although, surprisingly, it does NOT give the specifications of RAM. I've had the 32bit version (v3) since 2008

Basty

message edited by Sebastian42


Reply ↓  Report •

#23
January 22, 2019 at 06:36:15
Yes the trial expires in about 14 days. You also can stop the trial at the outset if you don't need it. Go to "Settings > Account Details" and you can end it there.

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

Ask Question