Commit 2ed913e5 authored by Amos Wenger's avatar Amos Wenger

Revert "set %USERPROFILE% since LoginUserW won't"

This reverts commit 009e8eea.
parent 009e8eea
......@@ -192,6 +192,7 @@ int runas(int argc, char** argv) {
toWideChar(parameters, &wparameters);
HANDLE hToken;
LPVOID lpvEnv;
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
......@@ -204,9 +205,9 @@ int runas(int argc, char** argv) {
wbail(127, "LogonUser");
}
// don't have enough permissions to NetUserGetInfo
// C:\Users is a constant even on non-English windows
SetEnvironmentVariableW(L"USERPROFILE", L"C:\\Users\\itch-player");
if (!CreateEnvironmentBlock(&lpvEnv, hToken, TRUE)) {
wbail(127, "CreateEnvironmentBlock");
}
wchar_t *ExePath;
toWideChar(argv[4], &ExePath);
......@@ -239,9 +240,7 @@ int runas(int argc, char** argv) {
if (!CreateProcessWithLogonW(wuser, L".", wpassword,
LOGON_WITH_PROFILE, wcommand, wparameters,
0,
NULL, // inherit parent environment
DirPath,
CREATE_UNICODE_ENVIRONMENT, lpvEnv, DirPath,
&si, &pi)) {
wbail(127, "CreateProcessWithLogonW");
}
......@@ -254,6 +253,10 @@ int runas(int argc, char** argv) {
wbail(127, "failed GetExitCodeProcess call");
}
if (!DestroyEnvironmentBlock(lpvEnv)) {
wbail(127, "failed DestroyEnvironmentBlock call");
}
CloseHandle(hToken);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment