writefile() fail with hidden or system files
Forum rules
You might want to read this if you're looking for priority service
Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).
Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.
How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
You might want to read this if you're looking for priority service
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
-
binocular222
- Posts: 1424
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
writefile() fail with hidden or system files
Error: Access denied
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
Filehero
- Posts: 2734
- Joined: 27 Feb 2012 18:50
- Location: Windows 11@100%
Re: writefile() fail with hidden or system files
What happens if you run XY as Admin?binocular222 wrote:Error: Access denied
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: writefile() fail with hidden or system files
actualy it just fails with readonly files. Maybe the target file had the readonly attribute set?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
binocular222
- Posts: 1424
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: writefile() fail with hidden or system files
Tried with XY as Admin; file has no "Read-only" attribute. Still access denied
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: writefile() fail with hidden or system files
then the file maybe locked by the system (or other process). I can do writefile() on any file, except for the ones with readonly.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
binocular222
- Posts: 1424
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: writefile() fail with hidden or system files
Strange, I tried this:
- Create new text file
- Set as hidden via Info Panel
- Close Info Panel
- writefile() still fail
Surely there's no thing access that file (used Lock Hunter)
- Create new text file
- Set as hidden via Info Panel
- Close Info Panel
- writefile() still fail
Surely there's no thing access that file (used Lock Hunter)
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
Filehero
- Posts: 2734
- Joined: 27 Feb 2012 18:50
- Location: Windows 11@100%
Re: writefile() fail with hidden or system files
You get the same message when trying to edit with e.g. Notepad/++?binocular222 wrote:Tried with XY as Admin; file has no "Read-only" attribute. Still access denied
Cheers,
Filehero
-
binocular222
- Posts: 1424
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: writefile() fail with hidden or system files
Notepad / Sublime Text has no problem writing to that file
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: writefile() fail with hidden or system files
okay, even more strange, writefile() fails, but appending data ( writefile("<curitem>", "data", a) ) works fine, even in quoted event.binocular222 wrote:Strange, I tried this:
- Create new text file
- Set as hidden via Info Panel
- Close Info Panel
- writefile() still fail
Surely there's no thing access that file (used Lock Hunter)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
admin
- Site Admin
- Posts: 67299
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: writefile() fail with hidden or system files
Wow, very interesting! I did not know that. There is apparently some hard-coded safety function in Windows that makes overwriting HIDDEN and SYSTEM functions fails unless the programmer explicitly allows it. Fix comes.
See http://msdn.microsoft.com/en-us/library ... 85%29.aspx:
See http://msdn.microsoft.com/en-us/library ... 85%29.aspx:
If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile fails and sets the last error to ERROR_ACCESS_DENIED if the file exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM attribute. To avoid the error, specify the same attributes as the existing file.
FAQ | XY News RSS | XY X
XYplorer Beta Club