Created
July 19, 2019 05:07
-
-
Save 3735943886/258d473263c97591f3e557306a6291cc 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