How to call system() in an opened administrator program and gives it the same privileges?
c++, windows, windows-7
Solution
If you use `system` you can use:
system("runas /user:<admin-user> \"program.exe\"");
Or `ShellExecute`:
ShellExecute(hwnd, "runas", "program.exe", 0, 0, SW_SHOWNORMAL);
This Stackoverflow Question details the `CreateProcess` method pretty well.
Problem
I am writing a c++ application in Windows that runs as administrator. However, while calling the `system()` command, it seems that the command doesn't have admin privileges (can't create file in the `C:\Program Files (x86)\` directory). How can I avoid using CreateProcess ?