# Scheduling a task with GPO to run as admin when user is logged



## whitlander (Jun 17, 2015)

I've been stumped by this for over a week now and read plenty of similar but not identical threads.
I have used Group Policy to scheduled a task. The task, which is set to run as domain admin, triggers a bat file which queries the registry and decides to run an exe. 

This above works perfectly when I set up the task as admin on a 'user config' GPO and log into machine as admin. However, when I log into a user's machine as the user, the task runs but the bat script is not triggered. I've had tried a few scenarios to troubleshoot this to no avail:

When I set a GPO under 'user config' and set the task to run as a specific user, the task runs perfectly but its not viable to iterate this method.

When I set a GPO under 'computer config' and set the task to run as a SYSTEM, the task runs but does not trigger the bat script. 

Selecting whether 'user is logged in or not' does not affect the success of the above scenarios.


----------



## fishscene (Apr 1, 2015)

I'm no expert, but since no one has chimed in here yet...
It seems running the task as "SYSTEM" or "End User" has the same exact issue.

I have no idea where this batch script resides, but if it's on a network resource, the "SYSTEM" account will not have access to it, and the "end user" may or may not have access to that network resource. 
Also, I'm not sure how you are able to tell if the batch file executes or not, but I assume you've inserted code to dump information to a log file at various stages of execution to see where in the script it is failing (and no log = didn't execute at all). Another point might be if the batch file is looking anywhere under "HKEY_CURRENT_USER" - the contents of that key change depending on who is logged in.

Assuming everything is correct with permissions on the batch file, and the batch file works properly..
It sounds like the batch file might be executed under the security context of the currently logged in user.


----------

