Has anyone found such behavior when Command Processor (cmd.exe) closes immediately after calling it? I’ve run McAfee AV and Windows System File Check (sfc.exe) and nothing wrong was detected, I’ve even copied cmd.exe file from other win 7 machine and it is still working same way. Strangest thing is – on the windows 7 64 there is also 32 bit version of that file which works perfectly normal.
SysInternals Process Monitor shows that cmd.exe process ends with exit code 0x0... o_O
Also calling commands directly from start menu, like ping, works normal…
Maybe that question is not strictly related to coding but that issue holds me from doing many things related to actual application development and environment check.
If a Command Prompt window opens up and closes quickly, it could be due to automatic maintenance task(s) kicking in. This is especially if the Command Prompt window flashes when the system is left idle for a few minutes.
If you want the command prompt cmd widnow to stay open after executing the last command in batch file –you should write cmd /k command at the end of your batch file. This command will prevent the command prompt window from closing and you'll get the prompt back for giving more commands in the cmd window.
Use Windows 10 System File Checker (SFC) If the system file is damaged, it may also cause the problem that CMD opens and closes immediately in Windows 10. For this, you can try to fix this problem by running the Windows 10 System File Checker (SFC).
To prevent the Command Prompt from closing automatically:Press Windows key + R to open the Run window. Adding / K after the command keeps the window open. You can, then, close the window manually when you no longer need it to be open.
Answering all questions:
Finally I got it SOLVED:
regedit
Go to HKLM\Software\Microsoft\Command Processor\
or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\
or HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\
For some reason there was AUTORUN key with "EXIT" inside.
AutoRun
key and everything should went back to normal.CMD.exe
should start to work again. Also,
In some cases, the Command prompt is also opening on Startup, which is when the above solution is applied hangs the system on Command prompt when you logon.
This can be fixed by using Autoruns, where you need to disable command prompt startup registries on Logon/Startup tab. (there can be more than one entries)
That one also explains why exit code was 0x0.
Have no idea what kind of thing set that key up... McAfee showed some activity lat week and I've noticed it last Friday.
Hope these symptoms and my answer will help someone in future
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With