Avatar billede staalaben Nybegynder
20. november 2009 - 11:01 Der er 4 kommentarer

Software Installation

I am writing a little application to run on WinXP, Vista and Windows 7. The application is to be used in a big company where only system administrators are allowed to install. The users have a restricted account.

Here is my problem:
When the software is installed I place a XML settings file in the CommonApplicationData folder. The settings file has information on SMTP settings and local printer information (supplied by the administrator under installation). When the users run the program they have read-preveliges on the settings file but they can not write to it = they can not change the default printer since this is saved in the settings file.

How do I go about this? I have tried saving the file to the LocalApplicationData but this will place the file in the administrator's LocalApplicationData and thus unaccessable to the user.

Any ideas?

Best Regards
Staalaben

PS. Anwers in English or Danish are welcome :o)
Avatar billede lasserasch Juniormester
20. november 2009 - 11:17 #1
Instead of using XML file or .Config files to store this information you could use the reg. database. That would give you the same functions and if you store it in the right section of reg. db the user will have change permissions...

/Lasse
Avatar billede staalaben Nybegynder
20. november 2009 - 11:35 #2
Lasse,

Thanks for your reply!

I have never used the reg. DB. In which area does the users have change permissions? And how do I access the reg. DB from my C# Windows Forms application code?

Best Regards
Staalaben
Avatar billede lasserasch Juniormester
20. november 2009 - 12:14 #3
Every user that logges on to a computer will get its own section within the HKEY_USERS section in the reg DB. In this section you can store information.

However what you need is to store the information in the HKEY_CURRENT_USER section. That is the HKEY_USER section of the currently logged on user.

Take a look at this page. It has some good examples and a demo application to guide you...

http://www.c-sharpcorner.com/UploadFile/sushmita_kumari/RegistryKeys102082006061720AM/RegistryKeys1.aspx

/Lasse
Avatar billede staalaben Nybegynder
20. november 2009 - 13:33 #4
Lasse,

I have tried but keep getting an SecurityException at the following line:

RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"software", RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl);

I am admin at my local machine and is running Win7.

/ Staalaben
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester