How to call ShellExecuteEx function to execute the "findstr / c:"[SR]" %windir%\logs\cbs\cbs.log > sfcdetails.txt"
How to call ShellExecuteEx function to execute the "findstr / c:"[SR]" %windir%\logs\cbs\cbs.log > sfcdetails.txt"
You can refer to the following code:
#include <windows.h>
int main()
{
SHELLEXECUTEINFOA lpExecInfo{};
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = "cmd.exe";
lpExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = NULL;
lpExecInfo.lpParameters = "/c findstr /c:\"[SR]\" %windir%\\logs\\cbs\\cbs.log > sfcdetails.txt";
lpExecInfo.lpDirectory = NULL;
lpExecInfo.nShow = SW_SHOWNORMAL;
BOOL b = ShellExecuteExA(&lpExecInfo);
if(lpExecInfo.hProcess) WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
if (lpExecInfo.hProcess)
{
TerminateProcess(lpExecInfo.hProcess, 0);
CloseHandle(lpExecInfo.hProcess);
}
return 0;
}
4 people are following this question.