是否有可能只能通过code以管理员身份运行
操作系统:Windows
语言:C
OS: Windows Language: C
我有一个要求,例如,我不应该改变的exe文件的清单或exe文件的运行它以管理员身份属性。有没有做我的要求与CreateProcess的/ createprocessasuser API的任何机会。这可以通过API的ShellExecute来完成,但是我需要创建我处于暂停状态的过程。这只能通过CreateProcess的或createprocessasuser API来完成。
这将不胜感激,如果有人能指导我通过这些API运行一个程序作为管理员。
I have a requirement such as , I should not change the exe's manifest or the exe file's properties to run it as administrator. Is there any chance in doing my requirement with createprocess/createprocessasuser api. This can be done through shellexecute api, However I need to create my process in suspended state. this can only be done by createprocess or createprocessasuser api. It would be grateful,If some one can guide me in running a program as administrator through these api.
我觉得最简单的解决办法是途径你要推出,虽然的runas /用户的过程:管理员yourprocess.exe
或提供运行方式
字符串为的ShellExecute
的第二个参数。这似乎是无证功能强悍。
I think the easiest solution would be to route the process you're trying to launch though runas /user:administrator "yourprocess.exe"
or supply the runas
string literal to the second parameter of ShellExecute
. This seems to be an undocumented feature tough.
ShellExecute(
NULL,
_T("runas"),
_T("notepad.exe"),
_T(""), // params
NULL, // directory
SW_SHOW
);