How to set task via command line to run if in sleep - windows-7

I am scheduling a task in windows 7 via psexec to networked computers. The task is scheduled ok but I want to be able to set it to wake the PC if it is in sleep mode. I don't see anything in the docs on how to do that. Does anyone have anyway of doing this?

Related

Some Nircmd command not working on task scheduler

i currently try to make script that prevent user to mute volume using nircmd .
but the script is fine when i run manually but when i run using task scheduler but only 2 line of system sound script executed, i try to make 2 different script between system sound and application sound result still same only system sound script executed.
nircmd.exe setsysvolume 13104 -->Working on task scheduler and can manually run
nircmd.exe mutesysvolume 0-->Working on task scheduler and can manually run
nircmd.exe muteappvolume mstsc.exe 0 -->Not working on task scheduler and can manually run
nircmd.exe setappvolume mstsc.exe 13104 -->Not working on task scheduler and can manually run

Restart .bat file every 12 hours

i have a batch file on my server desktop called start.exe. I'd like to kill start.exe every 12 hours, than wait 2 seconds, and than restart start.exe. This should of course also work when no user is logged in on the server. So the workflow should be like:
Starting Windows Server
Starting start.exe
Restart every 12 hours
How can i achive this? With a script? With a task?
Run shutdown.exe in a scheduled task set to run every 12 hours. At a command prompt, type shutdown /? to see the options.

Command Prompt doesn't close after scheduled task runs

I have a job scheduled to run at 9:30 every day using Windows task scheduler. The problem is after it runs, the command prompt stays open. Does anyone know how to get it to close?
The full text in the "Add arguments (optional):" field is:
C:\WinPython64bit\notebooks\TreasuryTest.py exit 0
I have searched all over, but most fixes are for use directly in the command prompt, and it seems to function differently from the task scheduler.

Long running scripts in Windows command line

I am running a script on Windows command line that takes multiple hours to finish executing. During this time, I am required to keep my computer open or the script stops. I was wondering if there are any tools that I can use which would keep the script running even if I put my computer to sleep (or shut the computer down). Thanks!
If computer is put to sleep or shut down, programs cannot run on it by definition of these states. Possible workarounds might include:
Running script on a permanently running remote machine (i.e. server)
Preventing computer to go to sleep

Calling cscript.exe and passing a vbscript to call

I have scheduled a task in windows server 2008R2 ..I want to run a VBScript so when I setup the task I call the cscript at C:\Windows\System32\cscript.exe and in the arguments section I am passing //nologo //B d:\main\programs\copy.vbs /targets:contents but it is not executing my script ..If I call my script directly in the start program section it works fine but it's not working if I call CSrcipt and pass in arguments the status changes to queued but nothing happens after that..Can someone tell me what I am doing wrong here.
Also another question I have is that can we run 2 programs one after another in one task like when one script is finished I would like to start another script .
Thanks
Put this line at the top of your script and try again:
CreateObject("WScript.Shell").LogEvent 4, "Script running"
Unless you get an Information event with source WSH and event-ID 4, your script isn't running at all. Check the eventlog and the task's History tab for clues as to why that is. Also check the permissions of the script. Is the runas account of the task able to access/run the file? You can check that by starting a CMD instance as that user
runas /user:DOM\USER cmd
and then trying to run the script in that CMD instance.
Also double-check the task settings. As which user is it configured to run? With the user logged on or not logged on? Is "Run with highest privileges" enabled (in case UAC is enabled on your server)?
If the script does produce the abovementioned event that means it's running in principle, but something is going wrong in the process. You need to debug your script.

Resources