VBAHole22 Posted August 10, 2004 Posted August 10, 2004 Just the facts: The Villian: A mild-mannered vb.net exe that is set up to run each evening. It is supposed to go through a list of file paths returned from Oracle and search to see if the files still exist or if they have been deleted. This keeps the Oracle table synchronized with the file system each day. The Crime: Aforementioned exe starts each evening yet does not complete it's mission The Twist: Darn thing works when I click on it and run it. The Clues: - There is evidence that this thing is starting each night because it writes out it's start time to a transaction table in Oracle - It just never proceeds beyond that to the other values it is supposed to write to Oracle. - There are try catch blocks all over this thing to trap errors and send them to Oracle but none get posted. - This often happens over the weekend. At times there will be a failure on Friday evening and Sat and Sun will never proceed beyond the intial start time post. The Mystery: What is so different about this thing firing from the task scheduler and me clicking the exe? Why would one work and not the other? Could it have something to do with it not closing itself down? Very strange................ Quote Wanna-Be C# Superstar
Denaes Posted August 10, 2004 Posted August 10, 2004 I had similar problems... working in a bank creating automated backups, front ends to run other apps on the task scheduler. Most failed because they refused to give me the servers password. If there is a password, Taskmanager requires it to go off. What OS are you using? Don't run the app, but go into your scheduled tasks folder, find the task. It'll have the Name, when it's scheduled to run (ie 11:30 AM every day), it's Next run Time (11:30 AM Tuesday), last run time (last time it ran), Last Result and Creator. Your password needs to match Creator. If it's "Last Run Time" was never, it isn't running. To test it out in the Scheduled Tasks environment to see what's going on, rightclick on the task (normally the filename, but you can name it differently) and select run. This will make it act just like it's going off at it's schedule appointed time. and it may not run. If it's running Scheduled sometimes and not other times, there might be something else using the database and causing your app to not be able to open it. I know you know how, have your app produce a log. Just at each step having it print out a line "Begging X function" basically documenting where the logic is taking it and most definately if there is an error and when it quits. Timestamps help as well. Because I'm lazy I normally create apps that'll have no GUI with a GUI and just make the GUI a large textbox which displays all of the information. When finished I delete the textbox and all the txtOutput lines will show up as errors and are easily deleted as well. Quote
VBAHole22 Posted August 10, 2004 Author Posted August 10, 2004 Good advice. The password is correct. I entered it once when I add the task. I am the only user on this machine (Win 2k Pro) and I typically lock it with ctr-alt-del at night. It does show a last run time of yesterday evening but in the Result it has: 0x0 That could mean something. I will try the text file log idea. Although I have build in much error trapping code that sends messages to Oracle as well. I tried to build this thing to be bulletproof. The first steps it takes are to see if the Oracle connection can be opened and if all of the network paths it needs can be opened. If either of those fail then the app bails and writes the ex.Message to Oracle. I'll try to run it direct from task manager. It takes about an hour to run. thanks for the help. Quote Wanna-Be C# Superstar
Denaes Posted August 10, 2004 Posted August 10, 2004 0x0 That could mean something. I think 0x0 means it ran perfectly without errors. That's what my MP3 Alarm Clock on the Scheduler says. I tried to build this thing to be bulletproof. The first steps it takes are to see if the Oracle connection can be opened and if all of the network paths it needs can be opened. If either of those fail then the app bails and writes the ex.Message to Oracle. Not saying its your problem, but its comical logic. If the Oracle connection cannot be open it sends the message to Oracle? I don't know anything about Oracle, do you mean you're sending it to the application Oracle, or to the database you cannot open? But really... It runs fine normally, but sometimes it doesn't. The only thing I can think of is the log file. You need to find out EXACTLY what it's doing, what procedures its going through, how many itterations, how many files it's picking up. etc. IF you're just adding in this sort of debugging software now, a suggestion might be to create a procedure to initate it all, have it all dependant on a single variable or something. This way you can set it to false and not have to write out the entire log again, but you can setup your app to run in 'logged mode' by typing "myApp.exe -Log" or something like that with command aruments. If it takes hours to run because it points to a directory(s) with many files, try a test run where you point it at a directory(s) with a controlled number of files. I created an app that goes through a directory and sorts files by their extension. Makes an MP3 directory and puts all mp3s in there, a .avi directory, etc. Nothing grand, but nice to organize a download directory. When I tested it, I used the textbox and aimed at directories with only a few files set up for the purpose of testing. Last thing I want is an error and it deleting good files or throwing 800 exceptions :P Quote
VBAHole22 Posted August 10, 2004 Author Posted August 10, 2004 Yeah, I guess that was kind of silly. What I meant to say was that the app bails if the Oracle connection is not working, first thing. This way I get to start over during testing. It has never occured yet so I don't think that is the issue. You are right about trimming down for testing, that is always a good thing. I'm interested in one thing you wrote : myApp.exe -Log Are you saying that you can pass in parameters from a dos prompt when you start the exe? Would those be parameters to Sub Main()? Would they have to be optional or could I test to see if the param is null and then deal with it? I didn't know you could do that. Would the task scheduler be able to hold these params? Quote Wanna-Be C# Superstar
VBAHole22 Posted August 10, 2004 Author Posted August 10, 2004 And it worked this time! Unbelievable. It only crashes at midnight when nobody is around? It shouldn't have anything to do with other .NET apps running at the same time, right? It shouldn't have anything to do with the computer being locked, right? Maybe my password on this network has some kind of time restriction? I'm grasping for straws now, I don't know what to think. I'll let it go tonight again and see what happens. Could it be that it onlys runs once and that it some how is 'left open' so it can't run again? But the scheduler says that it has run last night. But I believe there is a disjunction between the scheduler and the app. I mean the scheduler just says go, it doesn't wait around to see what happened. but it does get that result code, which in this case is still 0x0. Hummmm..... Quote Wanna-Be C# Superstar
Denaes Posted August 10, 2004 Posted August 10, 2004 More Schedule Settings... I could imagine having your machine locked down might prevent some of your permissions from working, but I wouldn't know how - I don't do that. I'd try setting it to go off in 5 minutes and lock the machine and see what happens (when you have time to spare of course). Lets check your Properties for the Scheduled Task (rightclick->properties) On the Task tab, I see a setting "Run only if logged on" mine is unchecked. being "Locked Down" may count as being logged off temporarily. You might want to make sure it can run when you're not logged on. (thats default on XP Home) Settings Tab - in the power management I have three options. Don't start if running on batteries, stop if battery mode begins (those two are checked - I'm on a laptop) and Wake the computer to run this task. The last is not checked for me. If you're "Locked Down" you might be 'sleeping' or on some power conservation mode as well. Thats all I can think of to help other than recreating the problem and documenting what is happening. Quote
Denaes Posted August 10, 2004 Posted August 10, 2004 Are you saying that you can pass in parameters from a dos prompt when you start the exe? Would those be parameters to Sub Main()? Would they have to be optional or could I test to see if the param is null and then deal with it? I didn't know you could do that. Would the task scheduler be able to hold these params? Check out System.Environment.CommandLine I can't get more detail that that at the moment, though you could probobly check that out in the MSDN. I used it for an optional parameter for another app. Of course you have to perform a check to see if it was nothing, -log, -whateverElseYouMightWant. I didn't use multiple arguments, but I think it's all handled as one and you have to parse out the different ones if there are more than one. I just reinstalled XP Home last night and I'm on the Marathon VS.Net installation... MS must have compressed these CDs something fierce, it takes like an hour per cd of constant unpacking and copying. Oh yeah! time to start the second installation disc :) Quote
VBAHole22 Posted August 10, 2004 Author Posted August 10, 2004 On the Task tab, I see a setting "Run only if logged on" mine is unchecked. being "Locked Down" may count as being logged off temporarily. You might want to make sure it can run when you're not logged on. (thats default on XP Home) This setting is not present on Win2k. There is a security tab but that is just the standard permissions. That must have been a new setting they added to the task tab, I can see that might be useful to quite trojan horses and back doors that operate at odd times. I did flip the wake flag so maybe that will help. More testing, testing, testing. Not installing Whidbey huh? Reinstall of XP home. Hope you don't have to repeat all of this when SP2 comes out next week :-\ Quote Wanna-Be C# Superstar
Denaes Posted August 10, 2004 Posted August 10, 2004 This setting is not present on Win2k. There is a security tab but that is just the standard permissions. That must have been a new setting they added to the task tab, I can see that might be useful to quite trojan horses and back doors that operate at odd times. I did flip the wake flag so maybe that will help. More testing, testing, testing. Not installing Whidbey huh? Reinstall of XP home. Hope you don't have to repeat all of this when SP2 comes out next week :-\ Well, my XP Home comes with SP1 already. So installing it isn't too much of a chore. In fact installing it once sp2 comes out would be easier because most of those "fixes" would be wrapped up into the service pack. eh, it took me like 3 hours from reformatting the hard drive to getting everything configed and set up enough to run a game that I played for 5 hours :) I've had MUCH longer turnaround times for installing OS's (win9x). I don't have MSDN subscription and access to vs.net 2005 beta. I had VB and C# 2005 express on my computer, but I kept getting pissed at it. I have projects to get done, but there is a "No Go Live" discosure on the 2005 beta products. So I'd keep saying "This is so cool!" "this is the easiest way to do it!" Then I'd remember that I couldn't release it targeting the 2.0 framework for another year (maybe less hopefully) and I'd get depressed and stop using it. It was like a tease. If i were just hobby programming I'd use VB or C# Express beta. Right now I'm studying for my MCADs which are based on 2003. Quote
Joe Mamma Posted August 10, 2004 Posted August 10, 2004 Try running the task as SYSTEM login Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Ontani Posted August 11, 2004 Posted August 11, 2004 if it stil isn't running try downloading a taskmanager from the internet if i'll run without asking what user is logged on Greetz Quote www.purevision.be :: www.devpoint.be
Denaes Posted August 11, 2004 Posted August 11, 2004 I just had a problem this morning. I have my music on my external hard drive since I just reformatted. I set Task Manager to one of the songs at 7am. My wife wakes me up about 7:30 and says "I thought you were going to set your music alarm" I go check and it says it didn't play. Took me like 5 minutes to realize it won't automatically run anything off of my external hard drive. ***? Why not. I paid for that drive to extend my windows computing experience. Who is Bill Gates to tell me what I can run and cannot run? Just out of principle I think I'm going to do a VB.Net Task Manager that actually lets you choose to run whatever you'd like, instead of leaving you in the lurches to possibly be late for work - or not run the database query at the right time - or not backup the hard drive every Friday at midnite and you don't realize until you've missed 8 backups and there's a problem. Quote
VBAHole22 Posted August 11, 2004 Author Posted August 11, 2004 http://www.codeproject.com/csharp/TSNewLib.asp Quote Wanna-Be C# Superstar
Ontani Posted August 11, 2004 Posted August 11, 2004 I just had a problem this morning. I have my music on my external hard drive since I just reformatted. I set Task Manager to one of the songs at 7am. My wife wakes me up about 7:30 and says "I thought you were going to set your music alarm" I go check and it says it didn't play. Took me like 5 minutes to realize it won't automatically run anything off of my external hard drive. ***? Why not. I paid for that drive to extend my windows computing experience. Who is Bill Gates to tell me what I can run and cannot run? Just out of principle I think I'm going to do a VB.Net Task Manager that actually lets you choose to run whatever you'd like, instead of leaving you in the lurches to possibly be late for work - or not run the database query at the right time - or not backup the hard drive every Friday at midnite and you don't realize until you've missed 8 backups and there's a problem. search on google for Active Task Manager you can run *.bat, *.exe and *.com files want to execute an mp3? just place a bat file into that folder with the commands: @echo off shell "wakeup.mp3" and run the bat file in the Task Manager I use it to automaticly update a gameserver stats every 4 hours. Great program ps: the bat files run silent, so you don't see them running Greetz Quote www.purevision.be :: www.devpoint.be
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.