Hi,
I am coding an application that requires the privileges of the logged in user.

I have checked the application to run with administrator privileges and upon executing it asks me if I want to run this application with admin privileges. Despite granting access when my code executes it doesn’t seem to be granted this permission level.

Any ideas why this wouldn’t work?

Chance

How can we help you if we don't know what your program needs the access for... And how do you know it's not working - is there are an error code like that says access is denied?

I am trying to run bcdedit.exe - it says that it cant find the file and i presume its a permission problem or something special about this file.

I know that my path to this file is correct:

char *path = "C:\\windows\\system32\\bcdedit";

and I invoke it with:

system(path);

How can we help you if we don't know what your program needs the access for... And how do you know it's not working - is there are an error code like that says access is denied?

It is not trivial to execute bcdedit from a C++ program...

If you open cmd.exe without admin permissions, it also will tell you that the command is not recognized (just bcdedit is enough.. you dont need the whole path), but if you open cmd.exe as admin it does work.

Also, opening cmd.exe with admin privileges, and then executing a C++ program that does system( "bcdedit" ); or CreateProcess( "paht_to_bcdedit", ... ); does not work.

So there is something special about the cmd environment that allows the execution of bcdedit, the environment where your C++ program runs is different from that.
I'm actually glad this is not possible, now not just any program with admin access can edit the boot options.

Why do you want to do this anyway? Maybe there is a better way to do what you want, without bcdedit.

I tried CreateProcess for him, to be sure but it suffers from the same problem.
Since I executed that from an elevated cmd I doubt it is at all possible (without a lot of hacking around)

Also I dont need access to change any details only to read from but bcdedit doesn't allow access unless its privileged.

This article has been dead for over six months. Start a new discussion instead.