?
Solved

Server 2008 R2 Batch File Scheduled Task Not Completing

Posted on 2013-12-30
12
Medium Priority
?
4,071 Views
Last Modified: 2014-01-16
I have 2 scheduled tasks that are both set to start a program, which is a *.bat file.

One of the scheduled tasks specifies a batch file, with the contents of that batch file containing a vbs file.  When executed manually it runs without issue, only through scheduled tasks it does not run.

I use the same account credentials in the task that I do when it runs.  I've also specified both just the Program/Script setting as the batch file, and also the Start in (optional) parameter in the folder path of where the batch file is located, and it still does not complete.

I have the same issue with another scheduled task that is a batch file, where the contents of that batch file is just a path to an Excel document.  Again, when the batch file is executed manually it works without issue, but does not work through scheduled tasks.

Other settings I have configured as:

Run as the following user: same domain user account that is used to run it manually
Run whether user is logged on or not
Run with highest privileges
Configure for Server 2008
0
Comment
Question by:fireguy1125
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 30

Expert Comment

by:Sudeep Sharma
ID: 39746294
Is there anything in the event logs about the task which are executed?

When you try to run the task from the TaskScheduler and choose it to run, does it run then?

Sudeep
0
 
LVL 1

Author Comment

by:fireguy1125
ID: 39746313
When I execute it by right click and run in task scheduleder, it shows status of the task is currently running.  

The time it takes to execute the batch file manually (without task scheduler) is under 5 seconds.  But I let the task run for several minutes and it still stays at the task is currently running, by that point I end the task manually.

Here are the events in my event viewer when I run the task, and then cancel it manually after 5 minutes because it does not complete:


Task Scheduler launched "{a73a1227-03d3-4d21-a114-2a20db12db92}"  instance of task "\Convert XLSX to XLS"  for user "TaskAdmin" .

Task Scheduler started Task Engine "S-1-5-21-1471991497-2808089978-3145653412-13858:DOMAIN\TaskAdmin:Password:Highest"  process. Command="taskeng.exe" , ProcessID=5644, ThreadID=5128

Task Scheduler started Task Engine "S-1-5-21-1471991497-2808089978-3145653412-13858:DOMAIN\TaskAdmin:Password:Highest"  process.

Task Engine "S-1-5-21-1471991497-2808089978-3145653412-13858:DOMAIN\TaskAdmin:Password:Highest"  received a message from Task Scheduler service requesting to launch task "\Convert XLSX to XLS" .

Task Scheduler started "{a73a1227-03d3-4d21-a114-2a20db12db92}" instance of the "\Convert XLSX to XLS" task for user "DOMAIN\TaskAdmin".

Task Scheduler launched action "xlsconvert.bat" in instance "{a73a1227-03d3-4d21-a114-2a20db12db92}" of task "\Convert XLSX to XLS".

Task Scheduler launch task "\Convert XLSX to XLS" , instance "C:\Windows\SYSTEM32\cmd.exe"  with process ID 4264.

Task Engine "S-1-5-21-1471991497-2808089978-3145653412-13858:DOMAIN\TaskAdmin:Password:Highest"  received a message from Task Scheduler service requesting to stop task instance "{a73a1227-03d3-4d21-a114-2a20db12db92}" .

Task Scheduler stopped instance "{a73a1227-03d3-4d21-a114-2a20db12db92}"  of task "\Convert XLSX to XLS"  as request by user "DOMAIN\TaskAdmin" .

Task Scheduler terminated "{a73a1227-03d3-4d21-a114-2a20db12db92}"  instance of the "\Convert XLSX to XLS"  task.
0
 
LVL 30

Expert Comment

by:Sudeep Sharma
ID: 39746332
Does any of your batch has ability to generate the log? Just making sure if we have anything in the logs which could point to the issue.

Sudeep
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 1

Author Comment

by:fireguy1125
ID: 39746336
Also, trying several combinations, I found that when the option to Run only when user is logged on is checked, it works.  It only seems to not work when I have the option to Run whether user is logged on or not.  How can I make it so it does.
0
 
LVL 1

Author Comment

by:fireguy1125
ID: 39746342
No, the contents of my batch files are very simple:

1st batch file (renames file extension  by using a vbs script):

C:\Scripts\xlsx2xls.vbs "C:\Reports\FromHR\active.xlsx" "C:\Reports\Rename\active.xls"

2nd batch file (executes xls file):

C:\Reports\Rename\active.xls
0
 
LVL 30

Expert Comment

by:Sudeep Sharma
ID: 39746343
So where are the files getting written or created?

Is this server in the domain?

Are you sure you are not writing to the User Profile which is on the File server?

Sudeep
0
 
LVL 1

Author Comment

by:fireguy1125
ID: 39746354
The files are getting created in a specified folder C:\Reports, C:\Reports\HR Reports, and C:\Reports\Rename directories.  I have verified all of these directories have full access permissions for the domain user account specified for scheduled tasks (it is the same domain user account I am logged into the server as well).

Yes, the server is on our domain.

No, there is nothing in the batch writing to local user profiles.
0
 
LVL 30

Expert Comment

by:serialband
ID: 39747315
What are you calling in your vbs script to do the conversion?  Does it pop up a dialog box?  Programs that need to pop up a dialog box can't run if you're not logged in.  Maybe you need to run a different program or figure out a switch to silence the dialog.
0
 
LVL 1

Author Comment

by:fireguy1125
ID: 39748210
The contents of my vbscript is:

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(Wscript.Arguments(0))
objExcel.Application.Visible = False
objExcel.Application.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs Wscript.Arguments(1), 56
objExcel.ActiveWorkbook.Close
objExcel.Application.DisplayAlerts = True
objExcel.Application.Quit
WScript.Quit

Open in new window

0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39750329
You don't need to use .Application here - skip that for making the script more simple.
Replace objExcel.ActiveWorkbook with objWorkbook.
That won't change the behaviour, but is better practise. In particular since accessing "Active*" is prone to failures, if e.g. the user or other applications perform actions while running the VBA/VBS code.
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39750345
As I've expected the "Run whether user is logged on or not" setting prevents Excel from being able to create visible windows. Change that setting, at least for the display task, and use just the Excel workbook name instead of a batch (no need to do that).
0
 
LVL 1

Author Closing Comment

by:fireguy1125
ID: 39786787
Thanks for all your patience and help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Six Sigma Control Plans

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question