I am developing a partition disk program, and for me to read the \\\\.\\PhysicalDrive0
I need admin rights.
I am wondering if it is possible, in the run time, for the program to gain admin rights? Is there any win api for that?
I want to do that because I want the program to execute with admin rights only when it is reading/writing the disk. For security reasons, I don't want the program to execute all the time with admin rights, because someone could find a bug (stack or heap overflow for example) in some module and execute arbitrary commands as adm.
In most of the cases, this issue occurs when the user doesn't have sufficient permissions to access the file. So I would suggest you to take ownership of the file and then check if the issue persists.
You cannot acquire elevated privileges after the process has started. Your options are:
requireAdministrator
.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