User forums > Help

cannot run .exe file from File Explorer

<< < (2/2)

TageB:
OK sodev,
I was writing a reply when your answer arrived so I didn't see it.
As I understand you, there is no way to run the program, keeping the result window open, and quitting the program from File Explorer.

TageB:
sodev,
Could you or someone else give med give me an example of a shell script I could run from File Explorer.
Suppose it should have the exe file as an argument, open a shell, running the exe file from shell, and then the program ends and the shell stays open? I am not used to good shell scripting...

sodev:
Well, a very basic solution with hardcoded application name that requires the application to be in the current working directory (which explorer sets to the directory of the script) would be like this:

launch1.cmd

--- Code: ---@echo off
prog1.exe
pause

--- End code ---

The premium version with hardcoded default application name and optional specified as command line parameter and the possibility to launch with a random working directory (but the application must be in the same directory of the script) would be like this:

launch2.cmd

--- Code: ---@echo off
set APPLICATION=prog1.exe

set BASEDIR=%~dp0
if not "x%1" == "x" set APPLICATION=%1

"%BASEDIR%%APPLICATION%"
pause

--- End code ---

TageB:
Thank you

Navigation

[0] Message Index

[*] Previous page

Go to full version