| View previous topic :: View next topic |
| Author |
Message |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Nov 01, 2005 2:06 pm Post subject: Shutdown error |
|
|
Hi,
First time poster (but I've been lurking long enough that I feel I like I know the regular posters). I can normally find answers to my questions by searching the forum, or asking a friend who uses VDS.
I have a small tray application that runs an application every 1 second. The problem is when shutting down Windows I occassionally get a "Application could not start" error from Windows. The occurance of the shutdown error is intermittant - i.e. it does not happen every time.
I have tried every solution I could find here, with varying success. I've even tried changing my tray app to call a vbs script instead of using devcon.exe. I also tried calling a batch file that ran the vbs script. I have even tried increasing the timer countdown and running my app with idle priority.
Currently the relevent bits of code look like this:
| Code: | OPTION SHUTDOWN,Close
rem dialog create stuff goes here
:Evloop
if @not(%%ShutDown)
timer start,1,ctdown,00-00:00:01
end
wait event
timer stop,1
goto @event()
:Close
%%Shutdown = 1
:Status
if %%ShutDown
stop
end
runh application.exe,pipe,wait
exit
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Nov 10, 2005 1:38 am Post subject: |
|
|
Hi DaveŽ
Welcome to VDSWorld. Your issue is a bit puzzling I never noticed that parameter to the OPTION command before. Anyway just to let you know that VDS gets a bit strange when you try to evaluate a variable that has not been initialize first in a loop and if I understand your code here it is basicly in a loop. Then again there could still be something wrong with the Option shutdown,close command... IMHO it may work better if you initialize the %%ShutDown varaible to 0 then test for 0 or 1 but it does not seem like that should be the problem. The only thing I can figure is that while Windows is shutting down your external program is trying to startup at the same time and Windows is not allowing it to do so. It seems to be a timing issue since your launching the program every second and sometimes the shutdown process for Windows can actually take longer than that to shutdown all the programs. You may want to try letting VDS shutdown naturally by removing the OPTION shutdown,close command.
Anyway welcome to the group and I hope you enjoy your stay  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Fri Nov 11, 2005 5:22 pm Post subject: |
|
|
Thanks for the welcome, dragonsphere.
The shutdown option was only added in an attempt to cure the problem. And since my original post I did add a %%shutdown = 0 for debugging. I've been writing the %%shutdown variable to a log file so I can check what value it had during both successful, and unsuccessful, shutdowns.
I've since tried replacing the countdown timer with a repeat loop (which doubled the cpu usuage):
| Code: | REPEAT
if @equal(%%ShutDown,1)
stop
end
runh application.exe,pipe
if @event()
%e = @event()
if %e
goto %e
end
end
WAIT ".1"
if @event()
%e = @event()
end
UNTIL %e
goto %e
|
| Quote: | | The only thing I can figure is that while Windows is shutting down your external program is trying to startup at the same time and Windows is not allowing it to do so. It seems to be a timing issue since your launching the program every second |
This is the same conclusion I've come to. If my application is past the point where it evaluates the %%shutdown variable, when Windows is shutting down, it will continue on and try to run the application (and fail because Windows won't allow the application to run). If it's at any other point in the program it closes down correctly. Increasing the timer countdown helps reduce the errors, but won't guarantee that the program won't one day be at that same critical point when Windows shuts down.
I believe the only solution is to replace running an external application with an API call - if possible - or a custom dll. _________________ cheers
Dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|