jakeflee
jakeflee

Reputation: 1

how do you execute .exe programs inside cmd using a batch file

I want to make a .bat file that will open recently compiled .exe files inside the command prompt (I have recently started to learn c++ but when I run my program it will open and close my program instantly) I want this program to run using the path to the compiled .exe my book says to make a batch file using a 2 line method:

[Program.exe]  
[pause]  

But I want to make one bat file to open any command prompt program and then stop I have this so far:

    @ echo off
    echo "input addres of file"  
    set /P file_a=[promptString]  
    echo "opening file %file_a% is this right? [y/N]"  
    set /P input2=[promotString]  
    if (input2)==("n")  
    GOTO @ echo off
    if (input2)==("y")  
    call file_a  
    pause      

it wont work can I get any help on this any would be nice.

p.s. I'm fairly sure the GOTO statement is wrong

Upvotes: 0

Views: 952

Answers (1)

foxidrive
foxidrive

Reputation: 41257

This is untested:

@echo off
:start
set "file_a="
set "input2="
set /P "file_a=input address of file "
set /P "input2=opening file %file_a% is this right? [y/N] "
if /i "%input2%=="n" goto :start  
call "%file_a%"  
pause     

Upvotes: 0

Related Questions