Solved

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

Posted on 2008-06-25
7
511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 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