Lock a text file while the script is running Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jose Hidalgo
Posts: 222
Joined: 07 Mar 2021, 07:44

Lock a text file while the script is running

08 May 2021, 06:12

Hi everybody, here's the thing :

I have a script that relies on another software's txt config file.
During script execution, that config file shouldn't be modified in any way, by any software.
Is there a way to lock that file during script execution, and release it on exit ?
Thank you.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Lock a text file while the script is running

08 May 2021, 06:51

If you rename the file, the other software would be unlikely to find it. You could also work with a copy of the file. Although you can set the file to read-only status, that would not prevent other software from changing the status again.
Jose Hidalgo
Posts: 222
Joined: 07 Mar 2021, 07:44

Re: Lock a text file while the script is running

08 May 2021, 08:54

mikeyww wrote:
08 May 2021, 06:51
If you rename the file, the other software would be unlikely to find it. You could also work with a copy of the file. Although you can set the file to read-only status, that would not prevent other software from changing the status again.
Thanks.
I cannot rename the file, because the other software still needs to be able to find it and read it. Just not write it.
I could set it to read-only permanently though, via Windows.
But isn't there a way to do it via AHK ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Theda and 177 guests