Commit 747ccc81 authored by Amos Wenger's avatar Amos Wenger

Include drive in dirpath

parent c9dfd110
Pipeline #1539 passed with stages
in 12 seconds
......@@ -210,15 +210,33 @@ int runas(int argc, char** argv) {
wchar_t *ExePath;
toWideChar(argv[4], &ExePath);
wprintf(L"ExePath = '%s'\n", ExePath);
wchar_t *Drive = malloc(sizeof(wchar_t) * MAX_PATH);
Drive[0] = (wchar_t) '\0';
wchar_t *DirName = malloc(sizeof(wchar_t) * MAX_PATH);
DirName[0] = (wchar_t) '\0';
wchar_t *DirPath = malloc(sizeof(wchar_t) * MAX_PATH);
DirPath[0] = (wchar_t) '\0';
_wsplitpath(ExePath, NULL, DirPath, NULL, NULL);
if (wcslen(DirPath) == 0) {
_wsplitpath(ExePath, Drive, DirName, NULL, NULL);
if (wcslen(DirName) == 0) {
GetCurrentDirectoryW(MAX_PATH, DirPath);
} else {
wsprintfW(DirPath, L"%s%s", Drive, DirName);
}
int LenDirPath = wcslen(DirPath);
if (DirPath[LenDirPath - 1] == '\\') {
DirPath[LenDirPath - 1] = '\0';
}
wprintf(L"ExePath = '%s'\n", ExePath);
wprintf(L"DirPath = '%s'\n", DirPath);
if (!CreateProcessWithLogonW(wuser, L".", wpassword,
LOGON_WITH_PROFILE, wcommand, wparameters,
CREATE_UNICODE_ENVIRONMENT, lpvEnv, DirPath,
......
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