JSI Tip 10611. How can I enable and start a service on all the computers in my domain?

Using Available.bat, I have scripted Start_Service.bat to configure and start the specified service on all available computers in the domain you are logged onto.

The syntax for using Start_Service.bat is:

Start_Service Service_Short_Name

Where Service_Short_Name is the short name of the service you wish to start.

NOTE: See How do I find the short name of a service?

NOTE: You must run Start_Service.bat from Windows Server 2003, or Windows XP, or a later operating system.

NOTE: Start_Service.bat will log the computer names that were not available in Start_Service.log in the current folder.

Start_Service.bat contains:

@echo off
If \{%1\}==\{\} @echo Syntax: Start_Service Service_Short_Name&goto :EOF
setlocal
set SVC=%1
set WRK=%SVC:"=%
set OK=N
call :QREG>nul 2>&1
if "%OK%" EQU "N" @echo Syntax: Start_Service Service_Short_Name - %SVC% does NOT exist.&endlocal&goto :EOF
if exist Start_Service.log del /q Start_Service.log
for /f "Tokens=1,2" %%c in ('Available') do (
 if "%%d" EQU "Y" call :strtsvc "\\%%c">nul 2>&1
 if "%%d" EQU "N" @echo %%c>>Start_Service.log
)
endlocal
goto :EOF
:QREG
for /f "Tokens=*" %%i in ('REG QUERY "HKLM\System\CurrentControlSet\Services\%WRK%" /V Start') do (
 set OK=Y
)
goto :EOF
:strtsvc
set OK=N
for /f "Tokens=*" %%s in ('sc %1 query %SVC%^|find "4  RUNNING"') do (
 set OK=Y
)
if "%OK%" EQU "Y" goto :EOF
sc %1 config %SVC% start= auto
sc %1 start %SVC%



TAGS: Windows 8
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish