Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem running a batch file as a scheduled task

Posted on 2010-11-11
25
Medium Priority
?
1,357 Views
Last Modified: 2012-05-10
This problem occurs on Windows Server 2008 x64 and Windows 7 x64.  I am running a batch file (.cmd) that starts 60 copies of an application that was written in Delphi 2010.  If I logon to windows and run this batch file it works perfectly.  If I run the batch file as a scheduled task, only 50 instances of the program get started.  The windows system log has 10 entries that read:

Application popup: Hcptransmit: HCPTransmit.exe - Application Error: The exception unknown software exception (0x0eedfade) occurred in the application at location 0x7683b727.

The scheduled task is setup to run with highest privileges and Run whether user is logged on or not.

Any ideas?
0
Comment
Question by:DavidCulbertson
[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
  • 9
  • 4
  • 4
  • +4
25 Comments
 
LVL 10

Expert Comment

by:cjrmail2k
ID: 34113752
are you running it as the same user? Also if you log on to (and lock) the server and let the task run, does it fail?
0
 

Author Comment

by:DavidCulbertson
ID: 34113824
No, I am running as a different user.  I need to be able to run this as a user that doesn't logon interactively.
0
 
LVL 10

Expert Comment

by:cjrmail2k
ID: 34113859
the first thig I would try is to change the task to run as the user you are logging on as, this will prove if its a permission issue
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:DavidCulbertson
ID: 34114002
I've logged on as the user that is running the task, and run the task.  It works perfectly.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 34114573
are the tasks long to execute ?
60 app running at the same time would be as long as only 10 tasks at the same time (if you don't have more than 10 cores on the computer)
so you could just create an application that will control the launch of those tasks with a maximum limit running simultaneously. When one finishes, you start the next on the list until done.

then your batch calls that application only
0
 
LVL 25

Expert Comment

by:epasquier
ID: 34114585
If you can wait monday, I can do that app for you
0
 

Author Comment

by:DavidCulbertson
ID: 34115118
The app's stay running for a couple hours, periodically checking a database and communicating changes to a remote location.  Each copy communicates to a different remote location.  It's easier for us to write a single threaded application and run 60 copies, than write a multi-threaded application.  I control the start of the app with a batch file that delays between the start of each application.  CPU utilization isn't the issue.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34122822
>delays between the start of each application
Maybe the 'time' has passed to start the scheduled task.
0
 

Author Comment

by:DavidCulbertson
ID: 34122868
The batch file reads:

start hcptransmit.exe
sleep 1
start hcptransmit.exe
sleep 1
.
.
.

The sleep program pauses 1 second.  It's the batch file that is scheduled to run, and it has not finished running, so I don't think that is the problem.  I have tried increasing the delay between each start with no luck.  

It looks to me like there is some limit in the OS for number of processes under a given scheduled task.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34122870
ignore that last comment.

trap the exception with a try ..except and get a clue to the error.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34123044
change from 100 to 200 the following keys

HKey_LocalMachine\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Configuration

    TaskInMemoryQueue
and
    TaskPerHighestPrivEngine
0
 

Author Comment

by:DavidCulbertson
ID: 34124414
Changed the registry, but no luck.  Application crashes upon start once about 50 are running.  If I run the batch file from a logged on session, every instance starts.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 34127836
Hard to tell, but most likely an issue with the desktop heap size for non-interactive sessions. For Windows 7 x64, the interactive heap size is set to 20MB, but for non-interactive its set to 768K. This heap is used for GDI/USER objects, and most likely your app uses a fair share of both. Add in the fact your trying to start 60 instances, and your problem might be there.

To test this:
1 . In Registry Editor, locate the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
2. In the right pane of Registry Editor, click Windows.
3. On the Edit menu, click Modify.
4. In the Edit String dialog box, locate the SharedSection parameter string in the Value data box, and then specify a larger value for the SharedSection parameter. The SharedSection parameter specifies the system and desktop by using the following format, where <xxxx> defines the maximum size of the system-wide heap (in kilobytes), <yyyy> defines the size of the per desktop heap, and <zzzz> is the size of the desktop heap for each desktop that is associated with a non-interactive Windows station:
SharedSection=<xxxx>,<yyyy>,<zzzz>

Example from my x64 Win 7 system (notice the setting of 768):
%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16

5. Click OK.
6. Not sure if its required, but restart the system to test.

I would suggest a setting of 1024 to see if this changes the count of instances that are able to start. eg.
... SharedSection=1024,20480,1024 ...

If no difference, then reset the number back. If this allows more (but not all 60) instances to be created, then bump it by another 256K. If this allows all 60 to be started, then your should be good to go.

---

hth,
Russell

0
 
LVL 46

Expert Comment

by:aikimark
ID: 34129367
maybe there is a (50) connection limit in your database.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 34129773
a tool for monitoring 60 databases ? and reporting to different locations
easier to write single threaded ?

what if you check all the databases the same way and store the report locally
and then distribute the report to the different location

sample:
App 1: Check database A, report to loc X
App 2: Check database A, report to loc Y
App 3: Check database A, report to loc Z

> better:
App 1: Check database A, report to loc X, Y and Z

less apps and less monitoring queries on database A ...
0
 

Accepted Solution

by:
DavidCulbertson earned 0 total points
ID: 34140406
Changing the settings in the registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
made no difference.

The database doesn't have user limits, and it works fine when I run it as a logged on user.

The reason we have multiple instances of the program is one process thread will not be fast enough when there are thousands of DB updates going out to every site.

I am currently testing a work around that looks promising.  I have setup two windows users with identical permissions.  I have two scheduled jobs, the first starts 40 instances of the program, and the second scheduled job starts the remaining 20 instances.  Each scheduled job logs on as a different user.  This is working on my test system.  I will be trying it in production tomorrow.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34144708
Run two sets of 30; 15 minutes apart. :)
0
 

Author Comment

by:DavidCulbertson
ID: 34159371
That works.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 34160377
Based on the latest author comment, the proper solution seems to be comment http://#34144708
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 34162530
i'd really consider a multithreading way
a lot easier to see if that's running than to count all the 60 processes running
0
 
LVL 46

Expert Comment

by:aikimark
ID: 34188422
@DavidCulbertson

In your original question text, you asked
>>Any ideas?

The http:#34144708 comment solved your problem, which you acknowledged in your http:#34159371 comment.  You did not ask a "why is this happening" question.  As such, your self-closing comment is not correct.
0
 

Author Comment

by:DavidCulbertson
ID: 34189072
Please read ID: http:#34140406 .  I was testing this solution and ID: http:#34144708 just re stated my idea.  When I stated "it works" I was referring to ID: http:#34144708 .
0
 
LVL 46

Expert Comment

by:aikimark
ID: 34189280
Thanks for that clarification.  In that case, I withdraw my objection.
0
 

Author Closing Comment

by:DavidCulbertson
ID: 34221169
My idea of splitting the job into two seperate jobs works.  I would have liked to find out why it doesn't work as one job, but this solution is working.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

715 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