xiao Posted March 25, 2009 Report Share Posted March 25, 2009 Recently, a system, running Windows XP, didn't work properly. We started an application by creating a task in the Windows scheduled tasks. In the schedule tab of the task, we set "Schedule Task" as "At System Startup". The task was a batch file, and its last command is ruby.exe with arguments (a script file). When the computer boots up, the scheduled task did schedule as expected. In our application (ruby.exe script.rb), it will launch another application (app2.exe) by calling "CreateProcess". Our ruby script code check the status of app2.exe every 5 seconds. If app2.exe didn't start properly, the script will call "CreateProcess" to launch app2.exe again. In the task manager, we did see that the app2.exe had been launching every 5 seconds, and the cycle never stops. In other words, app2.exe exits itself, or some one else kills it.However, when we put the exact same batch file in the Windows "Startup" folder and stops the scheduled task, the system boots up with a command prompt window. The ruby.exe can launch app2.exe successfully without any problem. So I am wondering what is difference between start a application from windows scheduled task and start from the "startup" folder? Does anyone have any suggestion? A few notes about the context, 1. The login user name has administrator privilege.2. Replacing the app2.exe with notepad.exe, and we didn't see notepad.exe was killed. However, we didn't the notepad.exe windows as well. The task manager showed notepad.exe is running in the background. Here I assume the app2.exe exits itself.3. For the 5 seconds interval check, we changed the interval to one minute. After the app2.exe exits itself, I can manually launch the app2.exe in the another command without any problem. In other words, the external hardware condition didn't prevent the app2.exe from existing. The only condition to cause app2.exe exit is when system reboots and ruby.exe was launched by scheduler task. Thanks a lot,-Xiao Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted March 26, 2009 Report Share Posted March 26, 2009 Welcome to the Windows Forum.I do not have the definitive answer for you, but some suggestions.Can you check the Event Viewer if you find any information why app2 is terminating.Is app2 your own applications? If so, can you put some diagnostics into it? Could you even launch it to run under a debugger? Quote Link to comment Share on other sites More sharing options...
xiao Posted March 26, 2009 Author Report Share Posted March 26, 2009 Thanks for your suggestions. app2.exe is our customer's application. I agree with you it is best to check app2.exe to get a reason why it exits. Unfortunately, it is really difficult to get it. In all scenarios, app2.exe can be launched without any trouble. The only trouble is that app2.exe can't be launched from the windows scheduled tasks during reboot. If we stop the task manually, and restart it, then app2.exe would work OK.Do you know what is the difference on launching an application between from the system scheduled task during boot and from the system start up folder? I used process explorer to compare the difference, I observed two differences, one is that environment variable difference and the other is that process launching tree. All other path, working directory, argument, security are all the same. When an application is started from the start up folder, it has a few extra environment variables, such as SESSIONNAME, LOGONSERVER, HOMEPATH, HOMEDRIVE, CLIENTNAME, and APPDATA. After I talked to my customer, he didn't think these environment variables matters in their application. So I have to focus on the process tree. In other word, there must be some difference between two launching methods at the boot time. When a process is launched from the scheduled task during reboot, and it must hold some resources which is not available to the child process.Another guess, the scheduled task started to run the task before we login into the system, while the application in startup folder will be launched only when a user logs in. The same question is what resources were held in that context to prevent app2.exe from running.Thanks,-Xiao Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.