Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug visual C++ application as administrator in Visual Studio 2012

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.

like image 279
jbx Avatar asked Dec 09 '12 23:12

jbx


1 Answers

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.)

like image 104
James McNellis Avatar answered Nov 12 '22 06:11

James McNellis