Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Foldermonitor with "/E" Option Issue

Dec
231
2
If I run the following:

FolderMonitor /C
FolderMonitor /S c:\ /E"JPSoft\Logs\Errors.log" MODIFIED 1 c:\JPSoft\Startup\A.btm 1
FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2​

And if both A.btm is:

@echo Start Action %1
@echo %_foldercount
@echo %_foldername
@echo %_folderfile1
@echo Done Action %1​

I get the following:

1
c:\
JPSoft\Logs\Commands.txt
Done Action 2​

The "FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2" command fired but the "FolderMonitor /S c:\ /E"JPSoft\Logs\Errors.log" MODIFIED 1 c:\JPSoft\Startup\A.btm 1" command didn't fire but should have fired. It was "JPSoft\Logs\Commands.txt" that caused the monitors to fire and not "JPSoft\Logs\Errors.log", so both FolderMonitor commands should have fired. So far it appears that the "/E" option disables FolderMonitor, I have not been able to get anything to fire when using a "/E" option.

Any Ideas?
 
One other thing that I noticed, if you put another FolderMonitor statement into the command statement of another FolderMonitor statement, as soon as the second FolderMonitor's condition is meet TCC crashes.

For example:

FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2
And A.btm contains:

REM Restart Monitor command after doing something
:
Do something
:
FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2​

As soon as a file gets modified a second time, the FolderMonitor from the A.btm crashes TCC.
 
One other thing that I noticed, if you put another FolderMonitor statement into the command statement of another FolderMonitor statement, as soon as the second FolderMonitor's condition is meet TCC crashes.

Why on earth would you want to do that??

The crash is in Windows code, so there's probably not much I could do about it other than forcibly prohibiting the action.
 
Because the “/W” doesn't work like I thought it would and “/E” doesn’t seem to work. If I set “n” (Number of repetitions) to 1, I only have to deal with the first occurrence, I don’t want to deal with all the others that may come after it. After processing the event, I may want to start monitoring the folder again.

I only want one event inside a critical section of the foldermonitor event handler. Semaphores maybe helpful to handle critical section of a batch script for the event handler, maybe something for version 20?
 
If I run the following:

FolderMonitor /C
FolderMonitor /S c:\ /E"JPSoft\Logs\Errors.log" MODIFIED 1 c:\JPSoft\Startup\A.btm 1
FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2​

And if both A.btm is:

@echo Start Action %1
@echo %_foldercount
@echo %_foldername
@echo %_folderfile1
@echo Done Action %1​

I get the following:

1
c:\
JPSoft\Logs\Commands.txt
Done Action 2​

The "FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2" command fired but the "FolderMonitor /S c:\ /E"JPSoft\Logs\Errors.log" MODIFIED 1 c:\JPSoft\Startup\A.btm 1" command didn't fire but should have fired. It was "JPSoft\Logs\Commands.txt" that caused the monitors to fire and not "JPSoft\Logs\Errors.log", so both FolderMonitor commands should have fired. So far it appears that the "/E" option disables FolderMonitor, I have not been able to get anything to fire when using a "/E" option.

Any Ideas?

Unless you've got a few terabytes of RAID 0 SSDs, I wouldn't recommend doing a "FOLDERMONITOR /S C:\"! Windows can write upwards of several thousand times a second to C: (for things like the page file).

The documentation for FOLDERMONITOR /E is slightly off. After some thought I decided to tweak the code so it would (also) support the syntax described in the docs; it will be in the next build.
 
Actual I was only using FolderMonitor /S C:\ for testing, I was only using "1" to "10" for repeats and never FOREVER. I was trying to workout how to handle a critical section within the event handler of the FolderMonitor. Using "1" for the repeat is one way of handling it but then you run into the problem of having to restart the FolderMonitor.
 
One other thing that I noticed, if you put another FolderMonitor statement into the command statement of another FolderMonitor statement, as soon as the second FolderMonitor's condition is meet TCC crashes.

For example:

FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2
And A.btm contains:

REM Restart Monitor command after doing something
:
Do something
:
FolderMonitor /S c:\ MODIFIED 1 c:\JPSoft\Startup\A.btm 2​

As soon as a file gets modified a second time, the FolderMonitor from the A.btm crashes TCC.

The problem here is that you are *still* inside the first FOLDERMONITOR call when "A.btm" is executed, so what you're doing is creating an infinite loop of FOLDERMONITOR calls, until TCC runs out of memory or resources.
 

Similar threads

Back
Top