I am embarrassed at having to ask for help here but I have spent enough time on it myself.
All that I am trying to do is run a batch file as a scheduled task in Windows server 2008. I have read most of the other similar issues on this site with no success. This server is the AD server & is logged on as the Administrator. The batch file is a very simple xcopy from one mapped drive to a local drive.
cd \
cd c:\users\administrator.DOM
AIN
xcopy g:\mergedata\*.* d:\guardebackup\backup /e /d /i /y > c:\merge.txt
According to the task scheduler history the script has completed with the result 0x0
Log Name: Microsoft-Windows-TaskSche
duler/Oper
ational
Source: Microsoft-Windows-TaskSche
duler
Date: 12/10/2009 7:52:42 PM
Event ID: 201
Task Category: Action completed
Level: Information
Keywords:
User: ROYALPARK\administrator
Computer: RPSrv01.chevronglass.com.a
u
Description:
Task Scheduler successfully completed task "\Hourly Backup of Guarde Data" , instance "{1d1a713f-8433-45ac-b39f-
f19548e29a
2d}" , action "C:\Windows\SYSTEM32\cmd.e
xe" with return code 4.
Event Xml:
<Event xmlns="
http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Ta
skSchedule
r" Guid="{de7b24ea-73c8-4a09-
985d-5bdad
cfa9017}" />
<EventID>201</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>201</Task>
<Opcode>2</Opcode>
<Keywords>0x80000000000000
00</Keywor
ds>
<TimeCreated SystemTime="2009-10-12T09:
22:42.127Z
" />
<EventRecordID>900309</Eve
ntRecordID
>
<Correlation ActivityID="{1D1A713F-8433
-45AC-B39F
-F19548E29
A2D}" />
<Execution ProcessID="8076" ThreadID="7684" />
<Channel>Microsoft-Windows
-TaskSched
uler/Opera
tional</Ch
annel>
<Computer>Server.domain.co
m.au</Comp
uter>
<Security UserID="S-1-5-21-436374069
-308236825
-180167453
1-500" />
</System>
<EventData Name="ActionSuccess">
<Data Name="TaskName">\Hourly Backup of Guarde Data</Data>
<Data Name="TaskInstanceId">{1D1
A713F-8433
-45AC-B39F
-F19548E29
A2D}</Data
>
<Data Name="ActionName">C:\Windo
ws\SYSTEM3
2\cmd.exe<
/Data>
<Data Name="ResultCode">4</Data>
</EventData>
</Event>
There is a second action configured, that sends me an e-mail & I receive that so the task completes but the batch file does not run. If I double click on the script it works. If I enter the script file into a command prompt it works.
I have tried the following.
1) Changing the .bat to a .cmd
2) Within the "Action" I have tried placing just the script file name, ie MergeDataHouly.bat & placing the location in "start in", ie C:\scripts as per another post.
3) I have edited the script to not change the current directory, ie just xcopy .....
Please assist in what should be a simple task