User forums > Help
cannot run .exe file from File Explorer
TageB:
Windows 10
CodeBlocks installed under D:\CodeBlocks\
path added: D:\CodeBlocks\MinGW\bin
Simple printout program is saved under D:\C-lib\progr1
Executes in CodeBlocks and in PC Shell ./prog1, but when trying to execute it in File Explorer (as administrator) a window pops up and closes immediately.
I have all permissions to the prog1.exe file. Virus program has also been turned off.
Why can't I run my prog1.exe file from File Explorer?
stahta01:
Try running it from an cmd.exe prompt.
Does it work?
Edit: Added link to fix the most common user mistake https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1042856625&id=1043284385
Tim S.
TageB:
It works in Code::Blocks, PowerShell (sorry I wrote PC Shell) and it works in cmd.exe.
I could not find any help in you link. I have installed the latest Code::Blocks and everything seems to work, except the built and compiled exe file, executed from File Explorer.
sodev:
You have build a console application that does some output and terminates then on its own. What explorer does is open a shell, run the program, and close the shell again after the program terminates. So what you are seeing is absolut normal and correct behavior.
Don't like it? Either prevent your application from terminating itself or write a simple wrapper shellscript that starts your program and pause's after it. Or simply start it manually in a shell like you already did.
TageB:
I got something from Tim's link. Thank you.
If I add 'getchar()' before the 'return 0' the window will stay open, showing the result, until I press enter.
But then I have to use 'enter' to quit the program, which wasn't the case when running it before in terminal.
So I would like a solution that shows the result and end the program, as in terminal.
Navigation
[0] Message Index
[#] Next page
Go to full version