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

x
?
Solved

task scheduler starts .EXE but EXE hangs

Posted on 2014-10-03
8
Medium Priority
?
394 Views
Last Modified: 2014-10-09
Hi.
We have a few VB applications that run nightly and are started from Task Scheduler on a server.  Those applications start, they do their thing, then close/end themselves, per code in the EXE itself.
I have a new one that I have set to start exactly like the others, but this one hangs once Task Scheduler starts it.  See ScreenCapTaskMgr1.JPG

In all cases, the Task Scheduler actually calls a .CMD (batch) file, and in the batch file is the command to start the EXE.   Similar to the others, the batch file for the one that does not work looks like this (shortened to 1 line for for testing):
start /d "E:\corpapps\Burns TSYS Batch" BurnsTSYSBatch.EXE 

Open in new window

The Task Scheduler calls the task as in ScreenCapTask2.jpg

All the other tasks are set to "Run whether user is logged on or not" and work fine, and this is the preferred setting.  The new EXE will run properly (not hang) only if this setting is set to "Run only when user is logged on".   See ScreenCapTask1.jpg

I can't blame the batch file -- If I run the batch file directly (double-click it) the EXE starts and closes itself, as it should.

What is different about this EXE is that it includes an ActiveX control that the others don't.   But, I reiterate here that the EXE runs fine on the server if I just double-click it, or double-click the .CMD file that starts it.

The EXE has a log file that it writes to immediately upon starting, and I noticed that when it hangs, it never writes to that file -- so it's not making it far through the code before hanging.

So, perhaps when the EXE is started as "Run whether user is logged on or not", it is actually executing in a "user space" that does not have the ActiveX registered?   I am logged in as Administrator, so you'd think there's not an "authority" issue.

Any suggestions?
ScreenCapTask1.JPG
ScreenCapTask2.JPG
ScreenCapTaskMgr1.JPG
0
Comment
Question by:Rob Rudloff
[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
  • 4
  • 3
8 Comments
 
LVL 83

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 600 total points
ID: 40360337
anything that interacts with the desktop must run when a user is logged on.
0
 

Author Comment

by:Rob Rudloff
ID: 40360494
"interacts" in what manner?
I have a test app that simply displays a form, then starts a timer which shuts down the app in 15 seconds.  I set up the same Task Scheduler & .CMD scenario as in my problem above.  Although I don't actually "see" the form displayed, I do see it the process (in Task Manager) start and stop automatically.
0
 
LVL 12

Assisted Solution

by:zalazar
zalazar earned 1400 total points
ID: 40362679
It might be that the ActiveX control do not require user interaction but does make calls to functions that require the application to be running in user interactive mode.
If this is indeed the case then it might be necessary to look into the code for things which are related to interactive mode (e.g. displaying forms/windows, making calls to (form) controls).
0
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 

Author Comment

by:Rob Rudloff
ID: 40365063
OK, I've been removing bits of code until the Task Scheduler successfully runs.  I also made some little test apps.

Actually, applications that display forms are fine --
The form never shows, but calls to open and close a form work fine (but are never actually seen).
Calls to ActiveX controls on unloaded forms work fine (as expected, the forms are loaded upon any reference made to a control on the form)
0
 

Author Comment

by:Rob Rudloff
ID: 40370341
I've requested that this question be closed as follows:

Accepted answer: 0 points for RobRud's comment #a40365063
Assisted answer: 250 points for David Johnson, CD, MVP's comment #a40360337
Assisted answer: 250 points for zalazar's comment #a40362679

for the following reason:

What fixed my app was removing a call to a function in a DLL.  
   
Wherever Task Scheduler runs programs "whether user is logged on or not" apparently does not have the DLL registered.  The DLL resides in the same folder as the EXE (App.Path).  The mystery is why it runs (with the DLL) outside of Task Scheduler, but not from Task Scheduler.

So, I suspect the DLL was not registered correctly.   This is a 32-bit app running on a 64-bit OS.   I unregistered the troubled DLL, and re-registered 2 ways, just to be safe:

c:\Windows\system32> regsvr32 "E:\corpapps\MyAppPath\Picky.DLL"
c:\Windows\SysWOW64> regsvr32 "E:\corpapps\MyAppPath\Picky.DLL"

One of those fixed the problem (I suspect the second).
0
 
LVL 12

Assisted Solution

by:zalazar
zalazar earned 1400 total points
ID: 40365625
Very good to hear that you found a solution and thank you very much for the detailed explanation.

When a DLL is registered with "C:\Windows\system32\regsvr32.exe", regsvr32 automatically recognizes if it's a 32-bit DLL and if it's 32-bit DLL it automatically calls the SysWOW64 regsvr32 version which registers it in the SysWOW64 environment but it's not a problem of course if you register it twice.

I understand that you like to close the question since you found the solution yourself.
The comments from David Johnson (and me) were pointing into looking into the code for things related to interactive and it did turn out that it was probably the DLL and not the interactive.
Stil I like to bring to your attention that altough the problem was solved by yourself you should not forget that we as "experts" are spending time on the question and trying to give comments which points into the right direction (like looking into the code).
Anyway, it's fine if you like to close the question and I'm glad it's solved.
0
 

Author Comment

by:Rob Rudloff
ID: 40365709
OK.  I'm going back and adding back in functions to the application and forms.  
I was considering removing all forms from the app just to get around the "interactive mode" limitation, but since it doesn't seem to be a limitation -- so I've left the forms in.  (The user does not need to do or see anything with the forms for my app to run.)

Can you provide clarity on "the code for things which are related to interactive mode (e.g. displaying forms/windows, making calls to (form) controls)" ?

What things won't run in "interactive" mode, so I know what to avoid?  From my test apps, it looks like the code that displays forms/windows doesn't fail, it just doesn't display to the user.  Same with calls to ActiveX controls on those "unseen" (but loaded) forms (which is now working for me, fortunately).   Do you mean just that ?  -- that if the user (not the code) needs to interact with the form, it must run in interactive mode?

Thanks.
0
 
LVL 12

Accepted Solution

by:
zalazar earned 1400 total points
ID: 40369582
Indeed what you describe about user interaction.
Displaying normal forms should be ok but modal forms/dialogs will not work. Reading a control from a modal form will probably also not work.
Within .NET there is a property which prevents displaying any modal dialogs or message boxes.
http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.userinteractive(v=vs.110).aspx
Best of luck.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

730 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