I'm trying to get the output of the powercfg -requests command from a vc++ program. However, it gives a output which is totally different from the output which is given when I manually execute the command in cmd.exe.
I tried to search about it and realized that I get the correct output when the cmd.exe and powercfg.exe present in "\Windows\System32" and get the different/undesired output when the cmd.exe and powercfg.exe present in "\Windows\SysWOW64" are used.
I tried to use CreateProcess and give the absolute path to both, as shown below:
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi;
printf("infoBuf : %S\n",infoBuf);
wchar_t cmdline[] = L"C:\\Windows\\System32\\cmd.exe /K C:\\Windows\\System32\\powercfg.exe -requests
wchar_t path[] = L"C:\\Windows\\System32\\cmd.exe";
if (!CreateProcess(path, cmdline, NULL, NULL, false, CREATE_UNICODE_ENVIRONMENT,
NULL, NULL, &si, &pi))
{
std::cout << GetLastError();
abort();
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
But the compiled executable still gives out the output similar to the 64 bit cmd.exe and powercfg.exe.
Am I missing anything? How else do I explicitly set and make sure that my program should use only the 32bit versions of cmd.exe and powercfg.exe.