Jump to content

Folder watcher doesn't work when folder has more than a few files


Recommended Posts

@Nine - May I ask if you can confirm one thing? There are a lot of quotation marks in that Run line. This version of the line seems to work when run from the script editor, but the child doesn't load when I run it as compiled. I'm obviously missing something, but after a lot of experimenting, I can't see what it is:

 

Run(@AutoItExe & " /AutoIt3ExecuteScript " & $sTempFile & " " & @AutoItPID & ' "' & $watchPath & '"', @TempDir, @SW_HIDE)

Apologies for bothering you yet again, after you've been so helpful and patient already!

Link to comment
Share on other sites

It works perfectly when I run the parent script by pressing F5 in the editor, but when I compile the parent and launch the executable, the child doesn't seem to get launched. Is it possible that this happens because my default file-association setting when clicking on a script is to open it in the editor instead of running it? I'm just guessing, because that presumably should happen when I run it from the editor. I can't test this until three hours from now, because I'm away from my work machine.

 

Link to comment
Share on other sites

Congrats.  You just found a bug.  I tested myself, both on Win7 and Win10, and it doesn't work.  I tried with a simple "Hello" MsgBox with .au3 extension, and if compiled it is not launching the child script.  I will report it as a bug.  Meanwhile, you could copy the file AutoIt3.exe somewhere and use the full path to start the child script.  Tested and working.  Or you could use @Tekk solution (untested).

Link to comment
Share on other sites

This is not a bug, but a feature.  https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine

Quote

Important Notes
However, the executable must have been compiled with the #pragma compile(AutoItExecuteAllowed, True) directive as the default setting does not permit use of the /AutoItExecuteScript or /AutoItExecuteLine parameters. Moreover, since the interpreter stub searches for any required standard #include files in its current folder, UDF functions and various constants may not be available as those files are normally only found in the full AutoIt install. It is therefore recommended that any scripts intended to be run in this manner are compiled to the .a3x format rather then being left as plain .au3 text files

Correct usage of single and double quotation marks is important when using the command line - even for double single quotation marks.
 

 

Adam

Link to comment
Share on other sites

@AdamUL - This tells me that we should always read the whole page of the Help file, instead of only the parts of the page we need. Yes, by putting the lline 

#pragma compile(AutoItExecuteAllowed, True)

near the top of the file, the child got launched. Many thanks for that alert response.

@Nine - Thank you again for this. I'm going to experiment with Tekk's method because it will be simpler to have a simple function for the Tray icon instead of building a script (I want to add about twenty more lines to my "information" message box, and I'm going to have to pass another command-line parameter to the script that you devised). But meanwhile, thanks to your help, I have a working script and I didn't have one before.

Link to comment
Share on other sites

  • 6 months later...
On 2/4/2020 at 12:19 PM, Nine said:

Or you may want to take a look at this :

...

Global $g_sPath = "C:\Apps\Temp\", $nBufferLen = 1048576
If Not FileExists($g_sPath) Then Exit MsgBox($MB_SYSTEMMODAL, 'Error', 'Unable to access folder')

Local $hDirectory = _WinAPI_CreateFileEx($g_sPath, $OPEN_EXISTING, $GENERIC_READ+$GENERIC_WRITE, $FILE_SHARE_READ+$FILE_SHARE_WRITE, $FILE_FLAG_BACKUP_SEMANTICS)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, 'Error', 'Unable to get handle')

Local $pBuffer = _WinAPI_CreateBuffer($nBufferLen), $aData

...

I have been using it successfully for quite some times now.  Downside, it is a blocking function.

Hello, @Nine !

I was just wondering how you chose the buffer size (1048576, or 1 MB) for your example. I'm hoping to monitor a subset of change types (just creations, deletions, and renames) for half a dozen entire multi-TB drives, if that's feasible (these changes will not happen very often, and virtually never to multiple drives at once). But surely that will require a very large buffer for each drive.

Can you or anyone else suggest how I should go about choosing appropriate buffer sizes?

Thanks!

Edited by Mbee
Link to comment
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
 Share

×
×
  • Create New...