Solved

Programically controlling advanced settings for schtasks.exe

Posted on 2006-06-25
6
2,499 Views
Last Modified: 2010-05-18
Being somewhat familiar with schtasks.exe I have decided to use it to control the running of defrag.exe.  I've gotten to the point of polishing the features.

My problem is I want to configure the tasks on many machines (13000) programicatically and I need to configure the following settings programically of course.

Don't start the task fi the computer is running on batteries
Stop the task if battery mode begins
Stop the taks if computer ceases to be idle
Stop the task if it runs for <file in the time period>

0
Comment
Question by:rj22
6 Comments
 

Expert Comment

by:esromneb
ID: 16978390
There is a wonderful program called autohotkey.  It it a very simple scripting language that will allow you to check for all of your conditions.  It will also allow you to to gracefully shutdown defrag once the computer goes on batteries.

Autohotkey also allows you to compile an exe out of the script, so you could just distribute and run the exe.

http://www.autohotkey.com/

P.S: may I suggest you also not run your defrag till the computer is idle?
0
 
LVL 69

Expert Comment

by:Merete
ID: 16981532
Hi rj22 I just dont think that is possible,there is no batch file or GPO that could regester  if the battery is running low?
It would have to be intergrated into that system and  on each system in a stand alone situation. Or intergrated into the mainboard sensors.

here is a good tip please browse thru to get some ideas.
http://www.windowsitpro.com/articles/print.cfm?articleid=50064
An extracted piece:
Diskeeper 10 runs as a service, monitoring system activity and performing automatic system idle-time defragmentation. Diskeeper 10 is intended to be placed into one of several "Set It and Forget It" scheduled modes; the product also supports standard time-of-day and day-of-week scheduling modes.

Management features. Diskeeper's new Administrator Edition is a console management program that lets you schedule and manage Diskeeper installations on servers and workstations across your network. Administrator Edition is a separate product and doesn't include the defragmentation engine.

 ====================================
 Discussion on Article: Scheduling Disk Defragmenter in Windows XP

You don't need to create a batch file, just create a scheduled task that has a run line like:
C:\WINDOWS\system32\defrag.exe c: -v>>C:\logs\defrag.log
http://techrepublic.com.com/5206-6230-0.html?forumID=5&threadID=195864&start=0
=======================================================
http://www.derkeiler.com/Mailing-Lists/securityfocus/focus-ms/2002-08/0077.html
-------------------------------------------------------------------------------------
risks posed by running task sched  manager on client  server
http://www.derkeiler.com/Mailing-Lists/securityfocus/focus-ms/2002-08/0077.html
0
 
LVL 24

Accepted Solution

by:
Kenneniah earned 125 total points
ID: 16987662
Since schtasks does not have those options, create the task first using the gui in control panel.
Then to deploy, just copy the .job file from C:\WINDOWS\Tasks and push it out to C:\WINDOWS\Tasks using whatever method you prefer.
The .job file copy method does not retain having the task run under the system account, so if you need that function, after pushing the .job file, have it run...

SCHTASKS /CHANGE /RU "NT AUthority\System" /TN "Yourtaskname"
0
 

Author Comment

by:rj22
ID: 16988576
Excellent idea!  Thanks much.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

19 Experts available now in Live!

Get 1:1 Help Now