Jump to content

No write previlege to INI file in %appdata%


DagSa
 Share

Recommended Posts

I have some problem to make my ini-file work properly. Purpose is to install program at windows 7 - 10 but think it work at XP also.
 I have included a fragment of code, but all my errors are there. It should be run by user privilege.
The test code point out what is not working:
Code is create a directory in %appdata%, and create a ini-file if not there. (This write of file work!)
When change the settings only one of the two parameters are changed. One value should be changed (don't work), and the other should be added (work!). Editing manually by notepad does not allow to save it.  I want the code to be able to change everything in ini-file.

1. First of all, the ini-file is not writeable by user when look at file properties and also directory properties. Any way to change this?

2. Is %appdata% wrong directory? I want all user to have access to the settings but its enough if only by control of the program.

It make me crazy its writeable sometimes, and sometimes not. Any ideas?
/Dag

AppData_INI-test.au3

Link to comment
Share on other sites

I use @AppDataCommonDir because its for all users.
%programdata% in Windows:
XP: C:\Documents and Settings\All Users\Application Data
Vista->10:  C:\ProgramData

@AppDataDir is for current user, but it have same properties for write/change as @AppDataCommonDir.
%appdata% in Windows:
XP: C:\Documents and Settings\All Users\Application Data
Vista->10: C:\Users\ <user name>\AppData\Roaming

It behave exactly the same in win7. Possible to write, but not overwrite or change.
Its essential to be able to read and write to a INI file in my opinion.
Isnt one of this folders the right one?
Any way to change the properties/privilege for "my" folder where the INI file is located?

Edited by DagSa
clearyfing
Link to comment
Share on other sites

As mentioned in @AppDataCommonDir is a System folder, unless you change the folder/file permissions using something like cacls or subinacl, you won't be able to write to a file within that directory unless you're a member of the local Administrators group.

Link to comment
Share on other sites

1 minute ago, jguinch said:

You need rigths. Try to add #RequireAdmin at the top of your code

This program should be used by a simple user, and program have some settings to be done like select a printer and save the setting, save the windows location so it could start at same place next time. You don't need Admin privilege for that.
Of course some other settings could be saved at time of installation with Admin rights, but not for the daily use.
Possible to give the software privilege to "my" settings?

Link to comment
Share on other sites

19 minutes ago, JohnOne said:

@DocumentsCommonDir

Tested, with same result. But progress
Folder is hide, so that's good. In win7: C:\Users\Public\Documents\_TEST

But the privilege is different for this folder and should not limit to read/write/change in INI file.
But the code don't work, so it must be something in code not working.
Possible to change and save by notepad.

Code don't change the phonenumber in INI file.

Link to comment
Share on other sites

The proper way is to build a program installer, required admin rights, which gives the good rights to all users to the application folder (using cacls on subinacl, like Subz pointed out)

 

Link to comment
Share on other sites

I found errors in code, because it was cutted out from other context. It works after some changes
I have a installer for the exe so its covered.
I test whats work and will be back with more info, thanks for support!
/Dag

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...