Task Scheduler- Batch "Run whether user is logged on or not" not working
Solution 1
To troubleshoot this here are a few things
- Logoff the machine you run this process as with the
User1
account and then log onto the machine as theUser2
account and ensure a profile gets built forUser2
. So theC:\Users\User2
folder should exist. - While you are logged onto that machine as
User2
run the scheduled task or at least test it withRun only when user is logged on
andRun 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 theRun 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. . .
- run command prompt (
cmd.exe
) from the machine you run the task on - run
schtasks
from the machine you run the task on - run
schtasks
remotely against the remote server you run the task against
Other Items
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.Compare the security differences with the
User1
andUser2
on remote machine, domain security groups, etc. as well.
Further Resources
Solution 2
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.
Related videos on Youtube
t_venuga
Updated on September 18, 2022Comments
-
t_venuga over 1 year
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 withRun 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
- Name:
Observations
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.
Question
How do I troubleshoot this sort of issue and where should I start to begin that process?
-
Paul about 5 yearsI have a similr problem. superuser.com/questions/1418031/… Did you find a solution?
- This batch file is configured as a Windows Task Scheduler job
-
fourpastmidnight over 2 yearsThis is done automatically when registering the scheduled task, as documented by Microsoft here, which is the very same link you posted. Also at that link, it's documented how to alter that default behavior.