Jump to content
Sign in to follow this  

Application returns 0 before running?

Recommended Posts

Hi All,

I have written some script that scans every folder down from a given directory and determines if any new folders have come into existence. I used it to scan a release server to determine when new revisions of source have been compiled into a stable version. If the script does not detect any new files, it Exits with Exit Code 1 (This is so that Jenkins knows to fail the given job, and not continue to the next job).

When I test the code on my local machine, a Windows 7 unit, Everything works normally and the exit code exits as "1", however when I run it on my windows 8 test system, The application immediately returns 0, and then a few seconds later actually runs (I can verify this is what's happening because of the files it generates, and the logging I create.)

What's even more annoying is that I have other Auto IT applications that work just find on the Windows8 unit, and Exit with whatever ExitCode I give them.

Is there something I may have set in the code that delays it running?

Share this post

Link to post
Share on other sites

Kevin, if I remember when I used to develop with Windows many years back, there is actually a file hook that you can trap and listen into. Scanning folders and files takes too much file intensive operations. You don't have to run jobs to scan the file system. Its a waste of resources.


Rather, what you want to do is listen in on the file changes and filter out only the directory and files you are interested in. You can keep a running change list and avoid having to clobber the file system every time you want to run a job to dirctory walk. In other words, let the events come to you, rather than you forcing the issue looking for them.

I'll point you to FileSystemWatcher class in the .NET Framework 4.5 for now to study. Have fun.

Share this post

Link to post
Share on other sites


Thanks for the tip. I currently moved the project onto another system and it works properly on that one. I'm currently using this as a band-aid just to get the project up and running again so I can focus on other tasks. I still don't know exactly what's wrong with it. As soon as I get a moment to come up for air, I'll check out FileSystemWatcher, and implement that in a new project to replace my current scanner. Your help is much appreciated.

To all other people viewing this thread who might have encountered the same issue with a script not running on a Windows 8 system, The only current work around I have was stop using the .exe on the offending machine and simply used it on another machine. I have no idea why this one machine stopped running this one program. Sorry

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By muchki
      i am more or less happy with my code
      only the X button does not exit
      what can i do?
      I made an 'exit' button and it works
      pressing Esc works
      just the X button not working
      here's my code:
      URLTrimmer 1.5.2 12 21 2019.txt
    • By IamKJ
      So I have a lot of different functions in the little program I'm making.  Most of them use the Do statement, such as finding images, clicking buttons, etc.
      The question I have is how would I be able to both
      1) Create a hotkey to pause whatever I am doing at the moment.  If I have to put something into every function in the program, I don't mind.
      2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
    • By ur
      I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end.
      Below is the part of code and the included files.
      #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <file.au3> #include <Array.au3> #include <String.au3> OnAutoItExitRegister("Exit_Program") Func Exit_Program() LoggingMainScr("Entered Exit_Program") Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"] ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod) EndFunc Func ExitProgram($sReason="Exit by user",$sCode=0) LoggingMainScr($sReason) if $sCode <> 0 then LoggingMainScr("stopped before completion") FileDelete(@ScriptDir&"\Machines*.txt") FileDelete(@ScriptDir&"\PsExec.exe") FileDelete(@ScriptDir&"\HyperVMachines.ps1") FileDelete(@ScriptDir&"\VMwareMachines.ps1") EndFunc Func LoggingMainScr($sMessage) LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log") EndFunc Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc Any suggestion.
    • By fopetesl
      For some reason my personal notes were omitted when posting.
      Still a Newb it seems! So have attached my slightly modified example.
      If I comment out Exit button references script will not Exit even with windows 'X' button icon.
      If I'm losing GUI/Tab focus I cannot see where is the difference with(out) definition.
    • By fosil
      Hi all,

      I'm working on a relatively complex automation program and I need it to call a specific function when it is closed by a user. Ive resorted to "OnAutoItExitRegister" as i believe that's the only option available.

      This command works perfectly fine in a small scale test application I wrote, but once implemented in the final program that's much larger and divided over many files in many directories it no longer works. I don't get any error messages.

      My question is has anyone encountered an issue where implementation of this command in a large scale program gave them trouble? Does it matter where "OnAutoItExitRegister" is called and where the function is located? Currently they are both places in the main file that runs the whole program but it still doesn't work.

      Any help is appreciated
  • Create New...