Sep
11

Stoping and Disabling Services

Filed Under (Scripting, Windows Server 2003) by on 11-09-2006

Another day another task…

 

Today I needed to stop and disable the Print Spooler and Telephony services on about 40 servers.  Sure if I got paid by the hour I could just log on to each individual server and do it manually but I don’t get paid by the hour and that is the kind of work any monkey could do…including me at times.  J

 

To solve this problem, I stood up I yelled “There has to be an easier way to do this!!!”.  Ok so I didn’t really stand up or yell for that matter.  What I have below is a script that will pull servers from a simple text document with server names on each line and then stop and disable both of those servers.

 

Hopefully this will save you some time when you are tasked with this silly task.

 

@echo off
set logfile=logfile.txt
for /f "tokens=*" %%a in (serverlist.txt) do call :stopservices %%a
goto end

:stopservices
echo Working on computer "%1"

net use %1
if errorlevel 1 echo %1 failed >> %logfile% & goto end

SC %1 config spooler start= disabled
SC %1 stop spooler
SC %1 config tapisrv start= disabled
SC %1 stop tapisrv
net use %1 /delete
echo %1 completed >> %logfile%

:end



Leave a Reply