Getting the HWND for an instance of cmd.exe from the process handle?

Getting the HWND for an instance of cmd.exe from the process handle?

Post by Dan » Thu, 05 Oct 2006 01:59:45

If I run a window's program with CreateProcess, then I can do the
following to explicitly bring it to the foreground ...

WaitForInputIdle (processInfo.hProcess, 5000);

EnumThreadWindows (processInfo.dwThreadId, EnumThreadsProc, NULL);

BOOL CALLBACK Event::EnumThreadsProc (HWND hwnd, LPARAM lParam)
SetForegroundWindow (hwnd);
return FALSE;

This works fine. However, it doesn't work if the program I'm trying to
run is "cmd.exe". Presumably this has no windows associated with it?
As there anyway I can generically bring a program to the foreground
with it's process handle?

- Dan

1. cmd.exe becomes unresponsive, need to kill the process

2. [C#] How can I sart a process in cmd.exe from a winform ?


I'd like to start dumpbin.exe from a windows form application.
However to start dumpbin.exe I need to start before cmd.exe with
vsvars32.bat to have the same configuration as visual studio prompt else
dumpbin does not work.

I know how I can start a process from a windows form application but I don't
know how I can start a process in another process.

I'd like to start cmd.exe and into cmd.exe I'd like to start dumpbin.exe.

Somebody knows how I can do it ?


3. Process and Cmd.exe problem

4. Starting a process "cmd.exe" from within a service...

5. System.Diagnostic.Process CMD.exe

6. W2K cmd.exe loses ability to start processes - memory leaks

7. Scary amounts of I/O for rogue CMD.exe process

8. Pb: System.Diagnostic.Process CMD.exe

9. Pb: System.Diagnostic.Process CMD.exe

10. fork processes in 'cmd.exe' window

11. Getting results back from CMD.EXE

12. i keep on getting the cmd.exe batch file popping up

13. Getting Copy-Item to display messages (like the old COPY command in CMD.EXE) ??

14. Can't install service packs. getting cmd.exe error

15. Getting instance handle from win handle