vc uac 提升运行权限
【摘要】 vc uac 提升运行权限
方式一:
方式二:
void GainAdminPrivileges(CString strApp, UINT idd) { CString strCmd; strCmd.Format (_T("/adminoption %d"), idd); SHELLEXECUTEINFO execinfo; memset(&execinfo, 0, sizeof(execinfo)); execinfo.lpFile = strApp; execinfo.cbSize = sizeof(execinfo); execinfo.lpVerb = _T("runas"); execinfo.fMask = SEE_MASK_NO_CONSOLE; execinfo.nShow = SW_SHOWDEFAULT; execinfo.lpParameters = strCmd; ShellExecuteEx(&execinfo); }
方式三:
NET SESSION >nul 2>&1 IF %ERRORLEVEL% EQU 0 ( ECHO Administrator PRIVILEGES Detected! ) ELSE ( ECHO NOT AN ADMIN! powershell start -verb runas '%0' am_admin & exit /b )
参考:
https://blog.csdn.net/youyudexiaowangzi/article/details/43484893
https://blog.csdn.net/Time2017/article/details/91954251
https://blog.csdn.net/whatday/article/details/39403199
https://stackoverflow.com/questions/133379/elevating-process-privilege-programmatically
https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)