Command Line Task Scheduler Power Options

demonzrulaz

New member
Local time
2:52 AM
Messages
1
Hi everyone,

I was trying to create a scheduled task via command line (schtask.exe) and I want it to run regardless of whether the user is on battery power or on AC power. I created an event and it runs fine on AC power but when I try it on the battery power, it doesn't work. I checked the task in the task scheduler and saw in the condition for my event the following options checked:
- Start the task only if the computer is on AC power
- Stop if the computer switches to battery power

After I create the task via command line, I can't modify the settings. Either way, I MUST only use the command line to create/modify the tasks. Is there any way to modify this variable? Or am I stuck on only having the task run on AC power?

Any help would be appreciated. Thanks!
 

My Computer

OS
Windows 7 Pro x86
Hello demonzrulaz, welcome to Seven Forums!


Perhaps I'm missing something, why can't you just use the Windows Task Scheduler for this?

Why MUST you use the command-line?
 

My Computer

Computer Manufacturer/Model Number
* BFK Customs *
OS
W 7 64-bit Ultimate
CPU
Intel Q9550 Yorkfield
Motherboard
ASUS P5Q Pro
Memory
8GB Dominator 8500C5D
Graphics Card(s)
ATI : XFX 5870
Sound Card
Realtek HD Audio 7-1
Monitor(s) Displays
1x 47" LCD HDMI & 3x 26" LCD HDMI
Screen Resolution
1920x1080P & 1920x1200
Hard Drives
1x 80GB Intel X25-M G2 SSD : 1x 500GB & 1x 640GB WD Caviar Black(s)
PSU
Corsair 620HX
Case
Cooler Master RC-690
Cooling
Tuniq Tower 120, 2x 140mm and 3x 120mm case fans
Keyboard
Microsoft 500
Mouse
Razer Diamondback 3G
Internet Speed
14 Mb/s
Other Info
1x Koutech 3Gb/s SATA HDD Hot Swap Rack
Why do you have to create the scheduled task in the command line? I can think of a couple reasons you might need to run it from the shell, but I'm interested to know why you can't create it from the wizard.

Also, have you checked out this site? http://msdn.microsoft.com/en-us/library/bb736357%28v=vs.85%29.aspx

I don't see the function you are looking for off hand, but it's a good general guide to the schtasks.exe functions.
 

My Computer

OS
XP Professional, 7 Professional
Okay, I appreciate that you guys want to make sure that demonzrulaz can't just use the GUI to set the power options, but here's a scenario for you: I'm trying to deploy software to 16 laptops with a script. The software needs to run as an administrative user in non-interactive mode on startup, but it needs to run regardless of whether or not the laptops are on AC. Now, is there a flag that hasn't been documented on Microsoft's site for power management? Or do I need to use some XML file? If so, what format does it need to be in (as there doesn't seem to be much documentation on that either)?
 

My Computer

OS
Windows 7 Pro 64-bit
In the case of randoogle, you can create your task in the GUI configuring your "on battery" settings. Then export that task to XML. On the command line, use the XML switch for your script.

I created a task with default power settings and then exported that task to XML. I then edited the power settings for that task and re-exported to XML. Comparing the files will show you the specific XML code that you can use:

<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>

<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>

<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>

<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
 

My Computer

OS
OS
Back
Top