Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1375
  • Last Modified:

Problem running a batch file as a scheduled task

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
DavidCulbertson
Asked:
DavidCulbertson
  • 9
  • 4
  • 4
  • +4
1 Solution
 
cjrmail2kCommented:
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
 
DavidCulbertsonAuthor Commented:
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
 
cjrmail2kCommented:
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
Independent Software Vendors: 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!

 
DavidCulbertsonAuthor Commented:
I've logged on as the user that is running the task, and run the task.  It works perfectly.
0
 
epasquierCommented:
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
 
epasquierCommented:
If you can wait monday, I can do that app for you
0
 
DavidCulbertsonAuthor Commented:
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
 
briangochnauerCommented:
>delays between the start of each application
Maybe the 'time' has passed to start the scheduled task.
0
 
DavidCulbertsonAuthor Commented:
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
 
briangochnauerCommented:
ignore that last comment.

trap the exception with a try ..except and get a clue to the error.
0
 
briangochnauerCommented:
change from 100 to 200 the following keys

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

    TaskInMemoryQueue
and
    TaskPerHighestPrivEngine
0
 
DavidCulbertsonAuthor Commented:
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
 
Russell LibbySoftware Engineer, Advisory Commented:
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
 
aikimarkCommented:
maybe there is a (50) connection limit in your database.
0
 
Geert GruwezOracle dbaCommented:
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
 
DavidCulbertsonAuthor Commented:
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
 
briangochnauerCommented:
Run two sets of 30; 15 minutes apart. :)
0
 
DavidCulbertsonAuthor Commented:
That works.
0
 
aikimarkCommented:
Based on the latest author comment, the proper solution seems to be comment http://#34144708
0
 
Geert GruwezOracle dbaCommented:
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
 
aikimarkCommented:
@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
 
DavidCulbertsonAuthor Commented:
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
 
aikimarkCommented:
Thanks for that clarification.  In that case, I withdraw my objection.
0
 
DavidCulbertsonAuthor Commented:
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

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 9
  • 4
  • 4
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now