GetNewestFile locks directory

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
vader
Newbie
Posts: 3
Joined: Tue May 27, 2014 12:31 pm

GetNewestFile locks directory

Post by vader » Tue May 27, 2014 12:38 pm

Whe I use GetNewestFile>DirName,FileList , the command locks the directory 'DirName' . Even the macro stops the lock is there.
MS must be closed to delete the lock.

What must be done to solve this ?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: GetNewestFile locks directory

Post by JRL » Tue May 27, 2014 2:13 pm

Interesting... Just tested, I've never used the function before. Its seems to be creating a temporary file at the path location and that file is locked by Macro Scheduler. The rest of the directory seems to be ok but that temporary file is untouchable.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: GetNewestFile locks directory

Post by JRL » Tue May 27, 2014 2:54 pm

A little more testing. In my initial test I was looking at my %temp_dir% and apparently locking temporary file being created by Firefox. The files were locked until I closed Firefox then they just went away on their own. Otherwise I'm not seeing any issues with GetNewestFile>. (Not that locking other apps temporary files isn't an issue, I'll be reporting it.)

Can you provide any more detail about your experience?

vader
Newbie
Posts: 3
Joined: Tue May 27, 2014 12:31 pm

Re: GetNewestFile locks directory

Post by vader » Tue May 27, 2014 3:07 pm

Hi,

I'm using Win7(64) and MS 14.1

It's very simple. The program loops and is waiting for incoming files, if a file is found it send a message and deletes the file.
After 10 minutes it closes himself. Now the parent program tries to delete the working dir, but it is locked by MS. Only when im closing MS complettly, the locks on this directory are removed.

Thank's for your fast answer.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: GetNewestFile locks directory

Post by JRL » Tue May 27, 2014 3:13 pm

I'll see if I can duplicate.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: GetNewestFile locks directory

Post by JRL » Tue May 27, 2014 3:46 pm

I can confirm your issue.

I compiled this script which creates a directory named VaderTest then writes a file to that directory every five seconds until it has written 5 files, Then it completes.

Code: Select all

CreateDir>%temp_dir%VaderTest
Wait>5

Let>kk=0
Repeat>kk
  Add>kk,1
  WriteLn>%temp_dir%VaderTest\temp_%kk%.txt,wres,Delete this file
  Wait>5
Until>kk=5

Wait>5
DeleteFolder>%temp_dir%VaderTest
MDL>VaderTest.exe Complete
Then started this script which looks for a file to exist in directory VaderTest, if a file exists the file is deleted. It deletes five files then completes.

Code: Select all

Let>kk=0

Label>ReDo
Wait>0.1
GetNewestFile>%temp_dir%VaderTest\*.txt,vFile

IfFileExists>vFile
  DeleteFile>vFile
  Add>kk,1
EndIf

If>kk=5
  Exit>0
EndIf

Goto>ReDo
Then ran the compiled script. The two programs ran to completion. The folder %temp_dir%VaderTest was not deleted by the executable and could not be deleted until I exited from Macro Scheduler.

Does this make sense?

Hopefully this can be addressed in the next release. In the mean time have you tried using GetFileList> rather than GetNewestFile>?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: GetNewestFile locks directory

Post by Marcus Tettmar » Wed May 28, 2014 9:43 am

I don't think this is caused by GetNewestFile. For one I can't see why it would.

In JRL's scenario I think this is caused by DeleteFile. If DeleteFile (which calls an operating system function) is deleting a file at the same time the .exe is trying to delete the folder, then clearly the folder can't be deleted.

I just commented out the DeleteFile statement from the second script and ran the test and the folder was successfully deleted. I think that proves my point. I ran the script over and over while the .exe was running.

The second script could call GetNewestFile as many times as it liked and it made no difference.

But put the DeleteFile back in and you get a collision between DeleteFile and DeleteFolder and the folder is not deleted.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

vader
Newbie
Posts: 3
Joined: Tue May 27, 2014 12:31 pm

Re: GetNewestFile locks directory

Post by vader » Wed May 28, 2014 10:19 am

I think it's the combination of GetNewestFile and DeleteFile.
The directory is locked when I use first GetNewestFile and then DeleteFile and this so on until the directory is empty.
This empty directory is locked until MS is complety exited.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: GetNewestFile locks directory

Post by Marcus Tettmar » Mon Jun 02, 2014 2:27 pm

I'll investigate some more.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts