The ProcessId returned here is NOT the one for MMC.exe (diskmgmt.msc) I think it was for cmd.exeĬout << "Process ID returned by CreateProcessA was: " << pi.dwProcessId << endl Ĭout << " This is NOT the process ID for MMC.exe (diskmgmt.msc)" << endl &pi) // Pointer to PROCESS_INFORMATION structureĬout << "CreateProcess #2 " << commandLine << " failed " << GetLastError() << endl If (!CreateProcessA(commandName_LPSTR, // Command NameįALSE, // Set handle inheritance to FALSE LPSTR commandName_LPSTR, commandLine_LPSTR ĬommandName = "c:\\Windows\\System32\\diskmgmt.msc" ĬommandName_LPSTR = const_cast(commandName.c_str()) ĬommandLine_LPSTR = const_cast(commandLine.c_str()) Ĭout << "Trying to start \"Disk Management\" using call to \"c:\\Windows\\System32\\cmd.exe\"" << endl Ĭout << " with \" /c C:\\Windows\\System32\\diskmgmt.msc\" added to end of commandLine" << endl Ĭout << " Using \"CreateProcessA\"" << endl << endl Ĭout << " Command Name := \"" << commandName_LPSTR << "\"" << endl Ĭout << " Command Line := \"" << commandLine_LPSTR << "\"" << endl << endl As a Console application no header files Note: This program is compiled under Microsoft Visual Studio Community 2019 ver 16.2.3 diskmgmt.msc can also be started from system(diskmgmt.msc) BUT how can I get the process ID? returned via pi.dwProcessId is not the pid for diskmgmt.msc (my guess it is for cmd.exe) I know diskmgmt.msc can be started via cmd.exe via CreateProcessA but the process ID can wait for "Disk Management" to be closed before moving on. This program tries to start "Disk Management" (diskmgmt.msc) and get the process ID so the program I have tried using "system("diskmgmt.msc") it starts Disk Management but it doesn't wait until Disk Management is closed. ![]() I tried using the pi.dwProcessId and looking for it using Task Manager but it is gone by the time the Disk Management is open, I think the Process ID was that of cmd.exe that started the Disk Management. I have tried calling "cmd.exe /c C:\\Windows\\System32\\diskmgmt.msc" from CreateProcessA.ĭisk Management will start but how can you wait for it to complete. I have tried "diskmgmt.msc" from CreateProcessA, it will not start. ![]() I'm trying to call the Windows 10 program "Disk Management" (diskmgmt.msc) and wait for it to be closed before continuing with the next part of the program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |