?
Solved

Strange behavour of a scheduled vb exe

Posted on 2009-12-21
6
Medium Priority
?
307 Views
Last Modified: 2013-11-10
I have created a VB6 exe to copy some set of files from one network location to the other.  It also worked well when i ran it directly.  But, the problem creeps up when i schedule the exe to run automatically.  I have scheduled it to run at 5 AM in the morning.

When i check that exe every morning, it will be running from morning 5 am to the moment i click on it.  When i click on that window it will get focus and then only it will continue its execution.  Until i click on that app window, it will remain still on the desktop but, will not be executing.

I tried changing the system, tried with different operating systems (xp/2003) and even i have rewritten that application in vb.net too. But, nothing helped!

I still have that problem and i need to click on that application window every morning to make it to continue its execution.

If somebody has faced a similar kind of problem or if anybody has some solution for this issue please reply back to me...
0
Comment
Question by:CIPL-Senthil
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:vinodsnair2001
ID: 26095011
Since a Window application requires users to be logged in in order to excute. Try to create a dos batch program or make this application to a windows service which doesn't need users to be logged in to the machine.
0
 
LVL 1

Expert Comment

by:Altwies
ID: 26105905
Try Creating a Timer that does a DoEvents in the timer thread, or executes the copy!

See if that works!
0
 

Author Comment

by:CIPL-Senthil
ID: 26143207
Hi vinodsnair2001,
Actually I think it doesn't require a login to run a scheduled windows application.  You can even find this option in task properties dialog of Windows scheduled tasks -- "Run only if logged on". 
However, I've disabled that property too, so that wouldn't make any trouble.  Apart from that, another noticable thing is that another application has also been scheduled for every 2 hours in the same system by my colleague and it runs perfectly every time.  I am also sure that the other application doen't make any impact on my problem because I have already tried scheduling my application in other systems  where there were no other applications scheduled with it.
So, I feel the problem lies somewhere else that I desperately wanting to know.  Any further help on this regard is highly appricated.
Thank you very much for your reply!
0
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.

 

Author Comment

by:CIPL-Senthil
ID: 26143312
Hi Altwies,  Thanks for the reply...  
Actually I have scheduled my application using Windows scheduled tasks, so I do not have the need to use timer in my application. And that do events stuff too:  what's the point of using do event at the begining of the process itself when an application just gets initiated. The other fact is, I have scheduled two other applications too (Windows applications) that I don't find to be making any problems, they runs exactly at time - no problems.
So, I think its some other problem..  Whatsoever I haven't got it yet and I definitely need you guys help finding the cause.  So, please suggest your solutions..
0
 
LVL 1

Expert Comment

by:Altwies
ID: 26143413
Hi again,

It may be that scheduling the app is not enough especially if windows decides it is not the active application. This is why I suggested a timer that activates a DoEvents() finction. This will guarantee that your app is the active apoplication.

Another thing to try is to call the Win API :
 SetWindowPos(hWnd, HWND_TOPMOST, 0, 0,  0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
0
 

Accepted Solution

by:
CIPL-Senthil earned 0 total points
ID: 26143488
Hi Guys,
I have identified the problem with the help of my colleagues.  Its about application activation.
When we directly run an application, first the form load even occurs and then followed by the form activate event.  But, when the windows scheduler invokes an application, the application is not getting activated, its just getting started, that's it.
In my case, the problem was I had written the code in form activate event and since my application is getting initiated through windows scheduled task and didn't get activated, it simply didn't continue with the code that i wrote in activate event.
So, I just moved the code to form load event and it worked.
However, my thanks for Altwies for his clue about activation and thanks for vinodsnair2001too for the response.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

839 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