-
-
Save sherief/a95fd51e8afac1ad461dd5628e653bab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <wtsapi32.h> | |
HANDLE CreateProcessActiveConsole(LPCTSTR app, LPTSTR cmd) | |
{ | |
static HANDLE hToken; | |
static STARTUPINFO si; | |
static PROCESS_INFORMATION pi; | |
ZeroMemory(&si, sizeof(STARTUPINFO)); | |
si.cb = sizeof(STARTUPINFO); | |
WTSQueryUserToken(WTSGetActiveConsoleSessionId(), &hToken); | |
CreateProcessAsUser(hToken, app, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); | |
return pi.hProcess; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment