Created
May 23, 2015 07:47
-
-
Save kleuter/ac791320c8bc75f842a9 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
bool CInstallMonitor::StartSuspendedSetupProcess(PROCESS_INFORMATION &pi) | |
{ | |
const CString setup_cmd = m_strSetupFile; // this is your setup exe e.g. C:\Documents and Settings\Administrator\Desktop\KillerCleaner_32bit.exe | |
// log | |
CString starting_text; | |
CString file_only = setup_cmd; | |
FileSystem::PathStripPathC(file_only); | |
starting_text.Format(locale("InstallTracker/logTrackingStarting"), file_only); | |
AddLogItem(starting_text); | |
// start | |
STARTUPINFO si; | |
ZeroMemory( &si, sizeof(si) ); | |
si.cb = sizeof(si); | |
ZeroMemory( &pi, sizeof(pi) ); | |
TCHAR command_line[2048]; | |
ZeroMemory(command_line, sizeof(command_line)); | |
bool bStartMSIProcess = (setup_cmd.Right(4).MakeLower() == L".msi"); | |
if (bStartMSIProcess) | |
{ | |
CString strMsiExecPath = FileSystem::GetSpecialFolder(CSIDL_SYSTEM); | |
FileSystem::PathAddBackslashC(strMsiExecPath); | |
strMsiExecPath += L"msiexec.exe"; | |
wcscpy_s(command_line, _countof(command_line), strMsiExecPath); | |
wcscat_s(command_line, _countof(command_line), L" /i \""); | |
wcscat_s(command_line, _countof(command_line), setup_cmd); | |
wcscat_s(command_line, _countof(command_line), L"\""); | |
} | |
else | |
{ | |
wcscpy_s(command_line, _countof(command_line), setup_cmd); | |
} | |
CString cmdLineFormat; | |
cmdLineFormat.Format(L"DEBUG: %s", command_line); | |
AddLogItem(cmdLineFormat); | |
return (::CreateProcess(NULL, command_line, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, NULL, NULL, &si, &pi) != FALSE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment