Logonuser和createprocessasuser从服务交互 [英] Logonuser and createprocessasuser interactive from service
问题描述
大家好
我正在尝试这种困难的方式,我想通过reateProcessAsUser API从服务启动一个流程,我有2个简单的行在RAM中加载了相应的用户,但我什么也没看到,因为我明白这个过程在另一个环境中运行,现在我正在尝试从两周开始,但我无法理解。
Cam你和我一起完成这个代码吗?
提前谢谢
Giovanni
Hi All
Im am trying this difficult way, i 'd like to launch a process from service with reateProcessAsUser API, with 2 simple rows i have the process Loaded in RAM with corrent User, but i don't see nothing, becouse i understood that process run in another context, now i am trying from two week, but i cannot understand as do.
Cam you complete this code with me ?
Thanks in advance
Giovanni
HANDLE hUserToken = INVALID_HANDLE_VALUE;
PROCESS_INFORMATION pi;
STARTUPINFO si;
BOOL bResult = FALSE;
DWORD dwCreationFlags = CREATE_NEW_CONSOLE;
LPVOID pEnv = NULL;
ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.lpDesktop = _T("winsta0\\default");
if (!LogonUser(Settings.szUserName, NULL, Settings.szPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken))
goto Cleanup;
bResult = CreateProcessAsUser(hUserToken, NULL, Settings.szCommandLine, NULL, NULL, FALSE, dwCreationFlags, pEnv, NULL, &si, &pi);
我尝试过:
i尝试过DuplicateTokenEX和SetokenInformation但总是失败我不知道该怎么做,真的:(
What I have tried:
i have tried DuplicateTokenEX and SetokenInformation but always fail i don't know what do, really :(
推荐答案
简短的回答是你出于安全原因不能这样做。
更长的答案是阅读本文 [ ^ ]。
The short answer is you can't do it because of security reasons.
The longer answer is Read this[^].
这篇关于Logonuser和createprocessasuser从服务交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!