Server 2008 R2 Batch File Scheduled Task Not Completing

Posted on 2013-12-30
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
Question by:fireguy1125
  • 6
  • 3
  • 2
  • +1
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?


Author Comment

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


Author Comment

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.

Author Comment

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):

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?

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.


Author Comment

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.
LVL 28

Expert Comment

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.

Author Comment

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.Application.DisplayAlerts = True

Open in new window

LVL 68

Expert Comment

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.
LVL 68

Accepted Solution

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).

Author Closing Comment

ID: 39786787
Thanks for all your patience and help.

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
detecting  the added row index in a datagridview 3 54
Undo a Print Server Setup 5 71
Issue while creating batch file using powershell 4 56
Windows 7 won't join domain 4 42
A short article about problems I had with the new location API and permissions in Marshmallow
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

930 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

13 Experts available now in Live!

Get 1:1 Help Now