Download MetaTrader 5

Win7 - what can I do to set a file read-only FOR SURE!

To add comments, please log in or register
Carl Schreiber
6989
Carl Schreiber  

Hi,


by using kernel32.dll I as normal user who started the mt4 that creates a file which at the end is set read-only:

SetFileAttributesA(TerminalPath() + "\\experts\\files\\" + fileName, FILE_ATTRIBUTE_READONLY);

But if I click on the Attributes of the file I see that for the users:

SYSTEM: FULL ACCESS

me as User (and owner): FULL ACCESS

me as root: FULL ACCESS

Home Users: READ, EXECUTE

Administrators: FULL ACCESS

So the file is NOT protected for being overwritten or deleted if a program (mt4) that I started wants to do that?

Very tricky of Win7 is the illusion that the files ARE protected - if you select them all - right mouse click you can see they are all right protected - but ONLY against Home-Users-group tat do not exist ion my pc - fantastic.

Hoe can I set the write-protection by a program out of mt4?

Anybody with a solution - other than that I do it file by file with the mouse - why do I have pc with programs if I have do do it myself anyway???

gooly

Simon Gniadkowski
Moderator
18019
Simon Gniadkowski  
gooly:

Hi,


by using kernel32.dll I as normal user who started the mt4 that creates a file which at the end is set read-only:

But if I click on the Attributes of the file I see that for the users:

SYSTEM: FULL ACCESS

me as User (and owner): FULL ACCESS

me as root: FULL ACCESS

Home Users: READ, EXECUTE

Administrators: FULL ACCESS

They are different things, user access rights != File attributes. A read only file should not be writable to even if your user account has Full access to it. Try it, create a text file, make it read only (file attribute) then try to write to it . . .
Ian Venner
2584
Ian Venner  

I dont think the read only file attribute has worked since Windows 95, you have to do it with permissions, it is confusing I messed up my whole computer one time by trying to change file permissions.

If you are using Windows 7 you have Windows Powershell already included so you can write scripts to do things like setting file permissions.

Carl Schreiber
6989
Carl Schreiber  
SDC:

I dont think the read only file attribute has worked since Windows 95, you have to do it with permissions, it is confusing I messed up my whole computer one time by trying to change file permissions.

If you are using Windows 7 you have Windows Powershell already included so you can write scripts to do things like setting file permissions.


Thanks, I had the fear that tis could be the case - at least in this case Linux is sooooo much better!!

Anyway do you have/know some Powershell-code to

a) change the file permissions meaningful without experiencing myself what you have gone through

b) from mt4 - script-file?

Thanks in advance,

gooly

Carl Schreiber
6989
Carl Schreiber  
Well I think I'll copy the fxt-files back inti \tester\history upon teststart (init() { if (IsTesting() ) { copy...
Ian Venner
2584
Ian Venner  
gooly:

Thanks, I had the fear that tis could be the case - at least in this case Linux is sooooo much better!!

Anyway do you have/know some Powershell-code to

a) change the file permissions meaningful without experiencing myself what you have gone through

b) from mt4 - script-file?

Thanks in advance,

gooly

No I didnt even attempt it lol, this technet article might be worth a read if you are still considering it.
To add comments, please log in or register