Zxian Posted December 20, 2004 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!
MCT Posted December 20, 2004 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
jdoe Posted December 20, 2004 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)
Zxian Posted December 20, 2004 Author Posted December 20, 2004 Awesome!!! This is exactly what I wanted...Thanks a million.
jdoe Posted December 20, 2004 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.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now