Solved

I need to configure scheduled tasks service to auto and then start the service on 50 + servers

Posted on 2008-06-25
7
496 Views
Last Modified: 2012-05-05
I need to configure scheduled tasks service to auto and then start the service on 50 + servers.  I am using psservice and a for loop to cycle throught the servers.  Attached is what I have so far.  Thanks.




Service.txt
Error.txt
0
Comment
Question by:radar365
  • 5
  • 2
7 Comments
 

Author Comment

by:radar365
ID: 21868667
I am also trying to get a log of each server and weather there was an error or it completed successfully for each server.  This way I can keep track of which servers I will nedd to go back and look at.
0
 

Author Comment

by:radar365
ID: 21869334
I believe I have the first script all jacked up.  I have tested this from 1 server resetting services on the other and it works but the function to set to the service to auto or disabled does not seem to be working for me.  Here is what I have for the psservice commnads:

psservice.exe \\mmtg1fnlp013 setconfig Scheduler start-auto  >>"%MyLogFile%"
psservice.exe \\mmtg1fnlp013 start schedule             >>"%MyLogFile%"

The service gets started and stopped, now I  beliave that I just need to get the startup type to set correctly and add a for loop.  Thanks for your assistance as I am still learning the poes with mass scripting.  Guess you need to make sure the comand will work on 1 first before you go creating for loops and all that... I got the cart ahead of the horse.
0
 

Author Comment

by:radar365
ID: 21869344
By the way my log file for this shows the following:

Usage: psservice.exe [\\Computer [-u Username [-p Password]]] setconfig <svc> <start-type>
Sets the start type of the specified service where start-type
is one of auto, demand and disabled.

I believe I have the syntax set correctly.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 26

Expert Comment

by:farhankazi
ID: 21872477
Check following batch script if this helps!

:: BATCH SCRIPT START 

@ECHO OFF

SETLOCAL EnableDelayedExpansion

SET InputFile=srvlst.txt

SET OutputFile=DisableStatus.txt

 

IF NOT EXIST "%InputFile%" ECHO "%InputFile%" file does not exist. &GOTO :EndScript

FOR %%R IN ("%InputFile%") DO IF %%~zR EQU 0 ECHO "%InputFile%" file is empty. &GOTO :EndScript

IF EXIST "%OutputFile%" DEL /F /Q "%OutputFile%"

 

FOR /F %%c IN ('TYPE "%InputFile%"') DO (

        ECHO Processing: %%c

        PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL

        IF NOT ERRORLEVEL 1 (

                SC \\%%c config "SentryII" start= auto >>%OutputFile%

				SC \\%%c START "SentryII" >>%OutputFile%

        )ELSE (ECHO Unable to connect %%c: system may be offline.))

 

ECHO. &ECHO Script complete. Check "%OutputFile%" file.

:EndScript

ENDLOCAL

EXIT /B 0

:: BATCH SCRIPT END

Open in new window

0
 

Author Comment

by:radar365
ID: 21874299
This is great and it works!!!  One last thing how would I also add the server name to the log so that I know which server if failed on if there was a failure?. Much Thanks.

SC \\%%c START "SentryII" >>%OutputFile%
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
ID: 21874344
You need to add following line inside IF condition block.
ECHO PROCESSING: %%c >>%OutputFile%
You can also add Date and Time like:
ECHO Date: %DATE%  Time: %TIME% >>%OutputFile%

Like:
:: BATCH SCRIPT START 

@ECHO OFF

SETLOCAL EnableDelayedExpansion

SET InputFile=srvlst.txt

SET OutputFile=DisableStatus.txt

 

IF NOT EXIST "%InputFile%" ECHO "%InputFile%" file does not exist. &GOTO :EndScript

FOR %%R IN ("%InputFile%") DO IF %%~zR EQU 0 ECHO "%InputFile%" file is empty. &GOTO :EndScript

IF EXIST "%OutputFile%" DEL /F /Q "%OutputFile%"

 

FOR /F %%c IN ('TYPE "%InputFile%"') DO (

        ECHO Processing: %%c

        PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL

        IF NOT ERRORLEVEL 1 (

                ECHO PROCESSING: %%c>>%OutputFile%

		SC \\%%c config "SentryII" start= auto >>%OutputFile%

                SC \\%%c START "SentryII" >>%OutputFile%

        )ELSE (ECHO Unable to connect %%c: system may be offline.))

 

ECHO. &ECHO Script complete. Check "%OutputFile%" file.

:EndScript

ENDLOCAL

EXIT /B 0

:: BATCH SCRIPT END

Open in new window

0
 

Author Closing Comment

by:radar365
ID: 31470701
You are a GURU of scripting.  Thank you. : )-
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn about cloud computing and its benefits for small business owners.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now