2

I have set of windows virtual machines, where I'm running a task every minute using task scheduler (schtasks.exe)

There is one batch file which creates the task, looks something like this:

SCHTASKS.EXE /Delete /TN "my_server" /F

SCHTASKS.EXE /CREATE /SC MINUTE /MO 1 /TN "my_server" /TR X:\mydrive\server.bat /RU %computername%\<username>

SCHTASKS.EXE /RUN /TN "my_server"

So this task runs every minute and every time it opens a command prompt window.

I want this task to run every minute but not open command prompt every time - it should run in minimized mode.

After googling for a solution, I've found few answers on stackoverflow itself to try /RU "NT Authority\System" instead of current user. So I've tried this as well:

SCHTASKS.EXE /CREATE /SC MINUTE /MO 1 /TN "my_server" /TR X:\mydrive\server.bat /RU "NT AUTHORITY\SYSTEM"

But it didn't work for me, not sure why. It didn't report any errors, I could see on command prompt "Task has been successfully created, Attempted to run the task", it scheduled the task but didn't start the task.

fixer1234
  • 27,064
  • 61
  • 75
  • 116
Ayush
  • 121
  • 2
  • Set the executable path as `cmd.exe /C /Q server.bat`. Or you may make a shortcut and set it to run as minimized. – Biswapriyo Jun 13 '17 at 08:24
  • This issue is likely the `SYSTEM` account cannot find the "X" drive nor would it likely have permission to it if it's a share on a server i.e. `\\server\share`... see here for much more detail about this: https://superuser.com/questions/1214736/windows-10-scheduled-tasks-with-workstation-lock-unlock-not-being-triggered/1217125#1217125 – Vomit IT - Chunky Mess Style Jun 16 '17 at 01:31
  • You might try something like this instead to make the batch script run invisibly regardless of which security context it is run as: https://superuser.com/questions/1113796/how-to-run-a-python-script-with-cmd-exe-and-make-it-invisible/1113801#1113801. See #2 section from this answer. – Vomit IT - Chunky Mess Style Jun 16 '17 at 01:32

0 Answers0