Batch script Help

Networking/Security Forums -> Programming and More

Author: duster PostPosted: Wed Feb 09, 2011 2:09 pm    Post subject: Batch script Help
    ----
Can someone assist me with this batch script. what i want to do is if the service is stop i want a echo message to print out saying starting dhcp. If the service is connected i want a message saying stopping dhcp. The script below work but not with the messages; i think i need to put it in a loop or something but im not good with scripting i found this sample on the net.


sc query dhcp| findstr /i running | if "%errorlevel%"=="0" (sc stop dhcp) else (sc start dhcp)

Author: georgec PostPosted: Thu Feb 17, 2011 10:28 am    Post subject:
    ----
try this one:
sc query wpcsvc | find /i "running" | if "%ERRORLEVEL%" == "0" (echo stopping service && sc stop wpcsvc) else (echo starting service && sc start wpcsvc)

I prefer to test with a less critical service Rolling Eyes



Networking/Security Forums -> Programming and More


output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group