Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
In advance excuss me if I dont make sense. I'm new to creating DOS bat files. I'm current trying to stop a service based on its state. Then writting a text file to be used for restart in the end of my bat file.
set service=cmsservice
for /f "tokens=3" %%a in ('sc query "%service%"^|find "STATE"') do (
if %cmsserviced%a==4 goto stop)
:stop
net stop cmsservice >> c:"\program files\motoplyr"\restart.txtif /I %EQU==1kb% c:\startup.txt goto startcms
if /I %EQU==0kb% c:\startup.txt EQU==0kb goto eofgoto :startCMS
:startCMS
net start CMSService
eof

First DOS has nothing to do with XP.
Next, I don't have any "sc query" in win2000.
But if you post the output of that command, maybe I can muddle through the script.
=====================================
Helping others achieve escape felicityM2

if %cmsserviced%a==4 goto stop
should be if %%a==4 goto stop
Next, think about what happens when %%a is not ==4. It will go to the next statement... which is the one labelled stop.
There are various other errors. I recommend you type the following and read the help text:
set /?
if /?
for /?

I remember doing this. I don't remember if it worked:
(net stop someService || net start someService) 2>NUL

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |