Solved

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

Posted on 2008-06-25
7
512 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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