I am developing an application which needs to save some settings to the registry. I am getting Error 5 when I try to open the key using RegCreateKeyEx
with KEY_WRITE
permissions. I use this approach so that the key is created if it does not exist. However when I run the same program with 'Run as Administrator' manually from the Debug folder it works fine.
Is there any way to run the application as administrator when debugging it through Visual Studio? I am using Visual Studio 2012.
You need to run Visual Studio elevated (i.e., with Administrator privileges). If you do this, then by default any processes started by it with the debugger attached will also run elevated.
(Visual Studio must be elevated in order to attach to an elevated process, for obvious security reasons.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With