I want to read all environment variable from the registry and set a new value for it with c# in visual studio 2010 express.
Thus I read the subkey of local machine:
SYSTEM\CurrentControlSet\Control\Session Manager\Environment and there the value of Path.
While reading the Path value:
reg = Registry.LocalMachine.OpenSubKey(SUB_KEY_PATH, true); I get an exception, that i don't have the permission for it.
Therefore I set the value in the manifest:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> But now I can’t compile my project, because ClickOnce doesn’t support it. How can I compile a project with security level of requireAdministrator? One solution I found is to compile it without the requireAdministrator level and afterwards I changed the value in myproject.exe.manifest. Did i see it right, that I always have to copy both files (manifest & exe-file) to another computer to run it correctly? Is it possible to put the information in the exe-file by compiling?