Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

How to elevate user rights when UAC level is set to default in OS for ShellExecute()API.

$
0
0

Hi,

I am trying to execute “elevate.exe” (my custom application) from another application, using ShellExecute () API. In this “elevate.exe”,  I am usingCStdioFile::open() API to  open a system file ( %windir%\System32\drivers\etc) in write mode (CFile::modeWrite), with below OS settings:

Log on User: Stduser (non admin user)

User Account Control settings : Default

Project settings (elevate.exe)->linker->Manifest File-> UAC execution level->requireAdministrator

With above scenario OS ask for admin credentials (popup dialog of “User Account Control”).

CString l_csPath =_T("C:\\TESTAPP\\elevate\\Release\\elevate.exe");
HANDLE child = ShellExecute( NULL,_T("runas"),l_csPath,NULL,NULL,SW_SHOWNORMAL);

Please help to elevate user rights for avoiding popup dialog of “User Account Control” OR can we pass admin credentials programmatically to execute above code snippet?  OR is there any other way to  elevate user rights for changing OS settings ?


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>