In use file/folder Topic is solved
In use file/folder
Is there a way to check that?
Re: In use file/folder
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
Re: In use file/folder
For file try this:
With regards to Folder, what would be the case when it is in Use? E.g. any of the file is in use?
Code: Select all
If !f:=FileOpen("C:\Temp\File.txt","w")
MsgBox Could Not Open File
else f.Close(),f:=""
Re: In use file/folder
An open command prompt on a folder will make it undeletable.HotKeyIt wrote:With regards to Folder, what would be the case when it is in Use?
Re: In use file/folder
This works with folders.
MyScripts is the name of a folder.
MyScripts is the name of a folder.
Code: Select all
IfWinExist,MyScripts
MsgBox yes
else
MsgBox no
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
Re: In use file/folder
I made a folder called temp on the root of c:\HotKeyIt wrote:For file try this:Code: Select all
If !f:=FileOpen("C:\Temp\File.txt","w") MsgBox Could Not Open File else f.Close(),f:=""
then created a text file called file.txt
The script exited with no message with no regard to if the file was opened or not. I also tried it on an existing text file on my desktop.
I am using windows 7 home premium. Ahk version 1.1.13.01 32-bit Ansi
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
Re: In use file/folder
Thanks for trying to help guys,
I need to overwrite all files and folders in a folder/dir only if no files inside that folder/dir/sub folder is in use.
None of the above works.
My solution for now is to try and rename that folder then check errorlevel and then rename it back. But thats too intrusive in my opinion.
I need to overwrite all files and folders in a folder/dir only if no files inside that folder/dir/sub folder is in use.
None of the above works.
My solution for now is to try and rename that folder then check errorlevel and then rename it back. But thats too intrusive in my opinion.
Re: In use file/folder
Sorry example was not correct
See documentation for FileOpen.
See documentation for FileOpen.
Code: Select all
fa:=FileOpen("C:\file.txt","r-rwd") ; comment this line to see the difference
If !(f:=FileOpen("C:\file.txt","r-rwd"))
MsgBox Could Not Open File
else MsgBox OK
Re: In use file/folder
@ HotKeyIt,
Doesn't work.
Doesn't work.
Re: In use file/folder
What do you mean?
Does it not say OK here?
And "Could Not Open File" here?
Does it not say OK here?
Code: Select all
If !(f:=FileOpen(A_ScriptFullPath,"r-rwd"))
MsgBox Could Not Open File
else MsgBox OK
Code: Select all
fa:=FileOpen(A_ScriptFullPath,"r-rwd")
If !(f:=FileOpen(A_ScriptFullPath,"r-rwd"))
MsgBox Could Not Open File
else MsgBox OK
Re: In use file/folder Topic is solved
@HotKeyIt,
It just doesn't work, not consistent.
It just doesn't work, not consistent.
Re: In use file/folder
You can use sysinternals handle.exe and parse the the result.There are plenty of option parameters to configure it.
http://technet.microsoft.com/en-us/sysi ... 96655.aspx
http://technet.microsoft.com/en-us/sysi ... 96655.aspx
Re: In use file/folder
You probably mean that not every program is locking the file, e.g. You can edit and delete a file while it is open in Notepad.Guest wrote:@HotKeyIt,
It just doesn't work, not consistent.
-
- Posts: 60
- Joined: 03 Oct 2013, 19:49
- Location: Seattle Area
- Contact:
Re: In use file/folder
Agree on using handle.exe as mentioned above. I've been using it for years, and it works in most but not all cases. It always seems to work if a file is being held open by the local file, but doesn't always work when a file is open across the network. It is however the best solution I've found.
One handy trick on it is to run it against a folder. If you do that, it will list all files in that folder that are currently open, which is what I do most of the time. I parse the results, and give the user a chance to close the handle or kill the offending process, then try again in a loop until it's done. I'd give you the code but it's 4NT code, so probably not that useful. Pretty easy to run it with RunWait and parse the results in AHK.
One handy trick on it is to run it against a folder. If you do that, it will list all files in that folder that are currently open, which is what I do most of the time. I parse the results, and give the user a chance to close the handle or kill the offending process, then try again in a loop until it's done. I'd give you the code but it's 4NT code, so probably not that useful. Pretty easy to run it with RunWait and parse the results in AHK.
Who is online
Users browsing this forum: No registered users and 124 guests