I've created a batch file (EnableDisable.bat) that will disable a Windows Task Scheduler job (SampleJob) on a local system, if a job with same name (SampleJob) is already enabled and running on another remote system.

It seems that when the job is setup with the Run whether user is logged on or not option checked along with Run with Highest privileges that it just doesn't work and the reason is hard to determine and I'm not sure how to troubleshoot.

Batch File

for /f "tokens=1" %%j in ('schtasks /Query /S [servername] /TN "SampleJob" /NH ^| findstr "Ready ^| Running"') do schtasks /Change /Disable /TN "%%j"

Note: The remote system is referred to as [servername] and will be replaced by the actual remote server name where needed.

Windows Task Scheduler Job Configurations

  • This batch file is configured as a Windows Task Scheduler job
    • Name: EnableDisableJob
    • Security Option: Run whether user is logged on or not
      • Run with Highest privileges


If I run the job with the Run only when user is logged on it seems to work just fine without any issue. However, it seems like when I try to run it with the other option, and because that account is not logged on, it cannot run when that is the case.


How do I troubleshoot this sort of issue and where should I start to begin that process?


To troubleshoot this here are a few things

  1. Logoff the machine you run this process as with the User1 account and then log onto the machine as the User2 account and ensure a profile gets built for User2. So the C:\Users\User2 folder should exist.
  2. While you are logged onto that machine as User2 run the scheduled task or at least test it with Run only when user is logged on and Run with highest privileges and this should pop up the command prompt window when it runs and show any errors, etc. which you wouldn't see running it with the Run whether user is logged on or not option. If you see an "access denied" error or something of that nature, then there's a permission issue.

Permission Issue

You will want to ensure the user account you run the Task Scheduler scheduled job with the Run whether user is logged on or not and Run with highest privileges has access to. . .

  1. run command prompt (cmd.exe) from the machine you run the task on
  2. run schtasks from the machine you run the task on
  3. run schtasks remotely against the remote server you run the task against

Other Items

  1. Make the User2 account a local admin on the machine you run the task on temporarily and then logoff and back onto the machine and and try again to rule that out local machine permission issues.

  2. Compare the security differences with the User1 and User2 on remote machine, domain security groups, etc. as well.

Further Resources


All suggestions above from Pimp Juice IT are great. I'll mention one other thing here.

You have to make sure the user account running the task has Log on as batch job user rights. Here's the doc from MS: link .

And here's a link on how to set this from Local Security Policy: link .

You can also do this via GPO.

Of course, as Pimp Juice IT suggested, if the user is already a Local Admin, they may already have this right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.