Windows Task Scheduler executing batch files

Windows Small Business Server 2011 (64 bit server)

Using task scheduler i scheduled a batch file to run. The contents are:
xcopy j:\*.* g:\data\backup\_fullback\j\*.* /S /C /R /Y /I
xcopy q:\*.* g:\data\backup\_fullback\q\*.* /S /C /R /Y /I

The name is fullbackup.cmd  (also tried fullbackup.bat)

When checked the day following the scheduled date, the scheduled tasks show that the batch file execution succeeded.  However none of the files were copied.

Double clicking on the same batch file outside of the task scheduler results in a successful execution.

Task Scheduler launch task "\Full Backup" , instance "C:\Windows\SYSTEM32\cmd.exe"  with process ID 40096.

Task Scheduler successfully completed task "\Full Backup" , instance "{3ee04b3c-cdf0-4f87-85fc-979e21a6b07a}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 1.

Task Scheduler successfully finished "{3ee04b3c-cdf0-4f87-85fc-979e21a6b07a}" instance of the "\Full Backup" task for user "FGIDOMAIN\bruce".

Any ideas?
bbornerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frank McCourryV.P. Holland Computers, Inc.Commented:
0
Jerry_JusticeCommented:
Task scheduler successfully ran the batch file, but it has no idea the xcopy commands within the batch file failed.

This problem is usually attributed to the account under which the task is supposed to run.

Did you set up the task to "Run as" you?  If so, did you check "Run only if logged on"?  If so, it will not run unless you are currently logged in.

If you set it up to run under a different account, then you have to worry about the account having rights to the files it is copying and to the destination.  You also have to make sure that account has a mapped or real "G:" drive.

I would recommend a task be set to use: "NT AUTHORITY\SYSTEM"  or simply "SYSTEM" as the account, if possible.  You would have to determine if the rights are appropriate to the resources.

Then, I would use a UNC instead of a mapped "G:" drive, if G: refers to a location on another computer.  i.e. \\TOMSPC\C\data\backup\_fullback\j
0
bbornerAuthor Commented:
Tried all of the below to no avail.
No matter what i attempt to run i get a run result off (0x1).
Am reading the help that comes with task scheduler which refers to using a cscript.exe to point to a script / batch file.  


Task scheduler successfully ran the batch file, but it has no idea the xcopy commands within the batch file failed.

This problem is usually attributed to the account under which the task is supposed to run.

Did you set up the task to "Run as" you?  If so, did you check "Run only if logged on"?  If so, it will not run unless you are currently logged in.


If you set it up to run under a different account, then you have to worry about the account having rights to the files it is copying and to the destination.  You also have to make sure that account has a mapped or real "G:" drive.

I would recommend a task be set to use: "NT AUTHORITY\SYSTEM"  or simply "SYSTEM" as the account, if possible.  You would have to determine if the rights are appropriate to the resources.

Then, I would use a UNC instead of a mapped "G:" drive, if G: refers to a location on another computer.  i.e. \\TOMSPC\C\data\backup\_fullback\j
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Casey HermanCitrix EngineerCommented:
Do you have the checkbox checked to "run with highest privileges" and "run whether user is logged on or not"?

if so then try the below.

modify your copy strings to look like the ones below

@echo on
xcopy j:\*.* g:\data\backup\_fullback\j\*.* /S /C /R /Y /I >c:\logcopy.txt
xcopy q:\*.* g:\data\backup\_fullback\q\*.* /S /C /R /Y /I >>c:\logcopy.txt

run it via task scheduler.

open the file at c:\logcopy.txt in notepad and see if it has any errors in it from the script.


-Casey
0
bbornerAuthor Commented:
Yes I did have the Run with Highest Priveleges checked.

I will try your suggestion to get log of the errors.

It runs perfectly if i just double click on the batch file.
0
Jon SverrissonIT SpecialistCommented:
I had the exact same problem you had on a SBS 2011. What you need to do, if you still have this problem, is to make sure that the following is configured:
1) Make sure that the directory where the batch file is located, is specified in the Action's properties Start in (optional) field. For example: c:\folder\batch\

2) You need to make sure that the account Local Service has full permissions both on the folder where the batch file is located and has full permissions to run the batch file. You check this by going to Security in the properties of the folder and the batch file. This is the most important part of making sure that TS can run the file.

3) Make sure that the task is run with the highest privileges and whether logged on or not.

This should do it.
Jon.
0
bbornerAuthor Commented:
Jon,
Will try your suggestions and get back
Thanks
0
Jon SverrissonIT SpecialistCommented:
Thanks bborner, I would appreciate your feedback.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Travola77Commented:
When using task scheduler did you use ' Create task'?
If so try using 'Create basic task' instead.
I had the same problem and that fixed it for me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SBS

From novice to tech pro — start learning today.