I'm trying to follow this, but on a Windows 10 system: Map network drive for the SYSTEM user in Windows with no success.
So I'm trying to just get any schtask to run as the SYSTEM account, for example "echo foo > E:\log.txt" or "net use >> E:\log.txt".
schtasks /create /tn "NAS-Test1" /tr "echo foo > E:\test.txt" /sc onstart /ru SYSTEM
They either run in perpetuity, or complete with an error code 2147942402. (Yes, E: is a local drive)
If I just run "net", it completes with code 2147942401.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create has these notes:
The System account doesn't have interactive logon rights. […] In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and the Logon Mode field has a value of Background only. […] SchTasks.exe displays an informational message and a success message, without prompting for a password: INFO: The task will be created under user name (NT AUTHORITY\SYSTEM).
For what it's worth, running a verbose query of the tasks returns:
Run As User: SYSTEM
Logon Mode: Interactive/Background
And I never get the aforementioned informational message. Not sure if it's only a matter of differences between Windows Server and 10.