Zxian Posted December 20, 2004 Share Posted December 20, 2004 Hey everyone,I'm trying to make some batch files that you can run to toggle the status of a service (in particular, the print spooler).I'd like to make the batch file something like...@echo offIF "print service started" ( net stop spooler) ELSE ( net start spoolerI'd like to keep my spooler service disabled unless I need to print something (usually only with Acrobat PDF) and I'd like a quick link to do this from the start menu or such.Any help would be appreciated.Thanks! Link to comment Share on other sites More sharing options...
MCT Posted December 20, 2004 Share Posted December 20, 2004 best way would IMO be to check the status of it via registry.. do a read from regi think the cmd is:set test REG READ key /v subkey /d valueif %test% = 2 goto good ELSE goto BADexit:net stop spooler2 = auto3 = manual4 = disabledfind the services reg key for spooler Link to comment Share on other sites More sharing options...
jdoe Posted December 20, 2004 Share Posted December 20, 2004 I think you're gonna have many tips for that.There's mine...@echo offFOR /F "tokens=1,2,3,4" %%A IN ('SC.EXE QUERY SPOOLER ^| FIND /I "STATE"') DO SET STATE=%%DIF /I "%STATE%"=="RUNNING" (NET STOP SPOOLER) ELSE (NET START SPOOLER) Link to comment Share on other sites More sharing options...
MCT Posted December 20, 2004 Share Posted December 20, 2004 yours looks better jdoe much more professional Link to comment Share on other sites More sharing options...
Zxian Posted December 20, 2004 Author Share Posted December 20, 2004 Awesome!!! This is exactly what I wanted...Thanks a million. Link to comment Share on other sites More sharing options...
jdoe Posted December 20, 2004 Share Posted December 20, 2004 yours looks better jdoe much more professional Your idea was not bad but reading the start value of a service don't give the live state of this service. The start value can be "2" (automatic) and the service can also be in a stopped state. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now