扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

createprocessasuser鎬庝箞浣跨敤

扬州沐宇科技
2023-07-08 22:20:49
createprocessasuser

鍑芥暟CreateProcessAsUser鐢ㄤ簬鍦ㄦ寚瀹氱殑鐢ㄦ埛浼氳瘽涓惎鍔ㄦ柊杩涚▼銆備互涓嬫槸浣跨敤CreateProcessAsUser鍑芥暟鐨勬楠わ細

  1. 纭繚浣犲凡缁忚幏寰椾簡瑕佸惎鍔ㄨ繘绋嬬殑鐢ㄦ埛浼氳瘽鐨勮闂潈闄愩€備綘鍙互浣跨敤鍑芥暟WTSQueryUserToken鑾峰彇鐢ㄦ埛浼氳瘽鐨勮闂护鐗屻€?/p>

  2. 浣跨敤鍑芥暟CreateProcessAsUser鍒涘缓鏂拌繘绋嬨€備紶閫掔殑鍙傛暟鍖呮嫭锛?/p>

  • 鐢ㄦ埛浼氳瘽鐨勮闂护鐗屻€?/p>

  • 瑕佹墽琛岀殑鍙墽琛屾枃浠剁殑璺緞銆?/p>

  • 鍛戒护琛屽弬鏁帮紙濡傛灉鏈夛級銆?/p>

  • 杩涚▼鐨勫畨鍏ㄦ弿杩扮銆?/p>

  • 杩涚▼鐨勫惎鍔ㄤ俊鎭€?/p>

渚嬪锛?/p>

// 鑾峰彇鐢ㄦ埛浼氳瘽鐨勮闂护鐗?/span>
HANDLE hToken;
WTSQueryUserToken(sessionId, &hToken);
// 鍒涘缓鏂拌繘绋?/span>
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CreateProcessAsUser(hToken, "C:\\Path\\To\\Executable.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  1. 纭繚鍦ㄤ娇鐢ㄥ畬璁块棶浠ょ墝鍜岃繘绋嬩俊鎭悗锛屼娇鐢ㄥ嚱鏁癈loseHandle鍏抽棴鐩稿叧鐨勫彞鏌勩€?/li>
CloseHandle(hToken);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

璇锋敞鎰忥紝浣跨敤CreateProcessAsUser鍑芥暟闇€瑕佺鐞嗗憳鏉冮檺锛屽苟涓斿彧鑳藉湪浜や簰寮忎細璇濅腑杩愯銆?/p>

扫码添加客服微信