Running a scheduled bacth script as SYSTEM (no password required) hides the cmd.exe window. In Windows 7, this can be done from the Task Scheduler GUI (Properties → Change User or Group...).
While Windows XP's Scheduled Tasks GUI appears to offer the same option (Properties → Run as:), tasks set to run as SYSTEM will fail with "Could not start"; see Microsoft KB223375, "Cannot Configure Scheduled Tasks to Use System Account"*:
When you create or modify a task in the Scheduled Tasks tool to use the System account, the task does not run as scheduled.
When you view the Scheduled Tasks log file, you receive the following error message:
The attempt to log on to the account associated with the task failed, therefore, the task did not run.
The specific error is: 0x80070057: The parameter is incorrect. Verify that the task's Run-as name and password are valid and try again.
This issue occurs because you cannot configure a task to use the System account using the Scheduled Tasks Wizard.
Currently, the only way to schedule a task as the System Account is to use AT.EXE to schedule the task. This command is shipped in Windows 2000 for backward compatibility for NT 4.0 scheduled events. Its defaults are to schedule jobs to run as the Task Scheduler service account (System by default).
To access this tool, open a Command Prompt (cmd.exe) and type AT /?. Be aware that after a job is scheduled using AT, manipulation of the task through the Scheduled Tasks folder will permanently change the job and turn it into a Windows 2000 Scheduled Tasks Job object (.JOB files). During this process, you must enter new credentials, and the only way to return the scheduled event to its original state using the system account is to delete and reschedule the event using AT.EXE.
An issue with using AT.EXE to schedule the task (e.g.,
at 09:00 /every:M,T,W,Th,F,S,Su c:\path\to\script.bat) is that properties are greyed out in the Scheduled Tasks GUI.
Tasks created with schtasks.exe, however (e.g.,
schtasks.exe /create /RU "SYSTEM" /SC daily /SD 04/18/2021 /ST 09:00:00 /TN "MyTask" /TR "C:\path\to\script.bat"), do not suffer from this limitation.
* In my testing, Scheduled Tasks → Advanced → View Log reported a different specific error:
"MyTask.job" (script.bat) 4/14/2021 7:52:32 PM ** ERROR ** The attempt to log on to the account associated with the task failed, therefore, the task did not run. The specific error is: 0x80041314: The task has been configured with an unsupported combination of account settings and run time options. Verify that the task's Run-as name and password are valid and try again.
/windows | Apr 18, 2021
Subscribe or visit the archives.