none
Launching Windows Command Prompt does not always show window. RRS feed

  • Question

  • Depending on how you attempt to launch a Windows command prompt ( CMD.EXE ) from another process the command prompt's window may or may not show up. Additionally the Windows On Screen Keyboard ( OSK.EXE ) will not start.

    Factors involved in the problem are:

    The "CMD.EXE" command string are contained in a script.

    CMD.EXE and OSK.EXE are being launch launched from a 32 or 64 bit Windows 7 or Windows 10 PC. All fail. Even when we fully qualify the paths(s).

    CMD.EXE does show up in the TASKMGR as a running process but no command prompt window pops up.

    If we add SysInternal's PSEXEC to the command prompt it seems to work. We'd like to eliminate psexec as a crutch.

    The user all processes are being launched in are Administrator.

    We've pretty much proven that Windows UAC virtualization is somehow involved in the problem. further more, during testing on a 64 bit machine we can see windows is redirecting to the SysWOW64 directory to fetch CMD.EXE and OSK.EXE. OSK.EXE is not even in the SysWOW64 directory.

    Any help suggestion would be appreciated.

    Al Harper


    Al Harper

    Wednesday, December 18, 2019 10:16 PM

All replies

  • Similar problems are solved with Wow64DisableWow64FsRedirection
    Wednesday, December 18, 2019 10:31 PM
  • Hi,

    Thanks for posting here.

    If you use the Win32 API to create a CMD process, specify CREATE_NEW_CONSOLE to generate a new console.

    CreateProcess(TEXT("C:\\windows\\system32\\cmd.exe"),NULL,NULL,NULL,false,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);


    If created in a script like ".bat" , you could use:

    start cmd /K

    In addition, As Castorix said, to disable file system redirection, use Wow64DisableWow64FsRedirection 

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 19, 2019 2:20 AM
    Moderator