Solved

Server 2008 R2 Batch File Scheduled Task Not Completing

Posted on 2013-12-30
12
3,905 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
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 29

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 29

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
 
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 29

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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 27

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 68

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 68

Accepted Solution

by:
Qlemo earned 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now