question

R99photography-6708 avatar image
0 Votes"
R99photography-6708 asked MotoX80 answered

Batch file of a scheduled task through GPO not working, it works when launched manually

Hello,
I have setup a GPO to deploy a scheduled task which runs a batch file available at server level.
The batch has been saved in both these locations:

I first tried with this:
\\servername\shared_folder\scripts

then this:
\\servername\SYSVOL\domain_name\scripts

The task is available at the domain computer client after the gpupdate /force command. Unfortunately, it doesn't work, I mean either at the scheduled time or by running it manually through the RUN button in the scheduler task app.
But... If I launch manually the batch file through the file explorer app, it works.

I cannot understand which kind of errors there are.

Here are the task details:

129349-task-1.png
129407-task-2.png

NT AUTHORITY\SYSTEM has FULL CONTROL at the folder (and file) where the batch file is stored.


windows-serverwindows-10-general
task-1.png (371.7 KiB)
task-2.png (207.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you please post the EXIT CODE as reported by Task Scheduler? This might indicate wether task scheduler has an issue finding your script or that it can find the script but the script errors out (that could be another possibility as not every script functions well when run as the SYSTEM user)

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hello R99photography

The default locations should be:

%SystemRoot%\SYSVOL\sysvol\<domain DNS name>\scripts.

or

%SystemRoot%\SYSVOL_DFSR\sysvol\<domain DNS name>\scripts (for DFS-Based FRS since as is recommended from Server 2012R2 and avobe)

If still don't run I would try to enable the synchronous load in the GPO:
"User Configuration -> Policies -> Administrative Templates -> System -> Scripts" to "Enabled

Also the logon delay settings at: Configure Logon Script Delay setting to Disabled in the Computer Configuration ->Administrative Templates ->System ->Group Policy

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered

If the script is local to the machine, don't use a UNC path (\\server\share), point directly to the drive. C:\MyData\Scripts\myScript.bat.

If you are trying to run a task on a workstation, and pull the script from a server over the network, then you will need to insure that the AD account for the machine (YourDomain\WorkStation1$) has access on both the share permissions and file permissions on the server since you are running the task as SYSTEM.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.