• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Search | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

Batch script Help

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
duster
Just Arrived
Just Arrived


Joined: 06 May 2005
Posts: 0


Offline

PostPosted: Wed Feb 09, 2011 2:09 pm    Post subject: Batch script Help Reply with quote

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)
Back to top
View user's profile Send private message
georgec
SF Staff
SF Staff


Joined: 15 Nov 2010
Posts: 0


Offline

PostPosted: Thu Feb 17, 2011 10:28 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Area

Log in | Register