Solved

Server 2008 R2 Batch File Scheduled Task Not Completing

Posted on 2013-12-30
12
3,994 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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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 29

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 70

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 70

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

705 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