Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run as administrator
Message
From
21/01/2011 11:12:19
 
 
To
21/01/2011 10:46:29
Antonio Llano
Inmollano S.L.
Getxo, Spain
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 3.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Miscellaneous
Thread ID:
01496318
Message ID:
01496871
Views:
38
You can't. Windows Vista and 7 prohibit access to the Program Files and Windows folders unless you are logged on with Administrator rights. That's why I said to do it during install, which runs with elevated privledge.

>Thanks Craig,
>
>The issue is that I need someway to change some AppSettings in the app.exe.config file, when the app is placed in the Program Files folder.
>I have written this method to do it:
>
>
>        public static void ReplaceAppSetting(String key, String value, ConfigurationUserLevel level)
>        {
>            Configuration config = ConfigurationManager.OpenExeConfiguration(level);
>            AppSettingsSection appSection = config.AppSettings;
>
>            if (appSection.Settings.AllKeys.Contains(key))
>            {
>                appSection.Settings[key].Value = value;
>                config.Save(ConfigurationSaveMode.Modified);
>            }
>            else
>            {
>                AddAppSetting(key, value);
>            }
>        }
>
>
>
>Usually users have administration rights but the app should be run as administrator, if not the config.Save() method fails.
>
>I´m trying to deal with the ConfiurationPermission class but I cannot güess how to program it to an unrestricted access.
>
>Any Idea??
>
>Thanks.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform