Keep Shellexecuteexw's Command Prompt Opened

I'm trying to use ShellExecuteExW to run a bat file. I want the command prompt to be kept opened after the bat file has been executed.

Here's what I tried,

SHELLEXECUTEINFOW TempInfo = { 0 };

TempInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
TempInfo.fMask = 0;
TempInfo.hwnd = NULL;
TempInfo.lpVerb = L"runas";
TempInfo.lpFile = L"cmd.exe";
TempInfo.lpParameters = L"\\k runMe.bat StartTool";
TempInfo.lpDirectory = NULL;
TempInfo.nShow = SW_NORMAL;

::ShellExecuteExW(&TempInfo);

But what I see is my cmd.exe stays opened but it didn't actually ran my runMe.bat file.

3

1 Answer

@dewaffled answered it... /k instead of \\k

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest