Sunday, May 30, 2010

Run Your .BAS Files in Windows Explorer

Want to double click your .BAS files in Windows Explorer and have them run by QB? Type the following text into your favorite text editor and type (or copy/paste) the following text:

REM qbrunner.bat
REM To install, place this bat in your QB folder,
REM right click on a .bas file and choose the
REM program to open with. Navigate to and select
REM this batch file. Then make sure you check
REM the "Alway use the selected program..." box.
REM After that you can just run .bas files in
REM Windows Explorer.

@ECHO OFF
CLS
PROMPT
COLOR 47
TITLE "%~n1" is now running...

REM Start in your file's folder
CD "%~dp1"
REM Change the path to QB on your computer
C:\QBasic\QB.exe /L /RUN %~nx1

ECHO.
ECHO.
ECHO.
TITLE WE NOW RETURN YOU TO YOUR SYSTEM
PAUSE


Save this file as qbrunner.bat in your QB install folder.

Next, right click on a .bas file. Select "Open With > Choose Program..."
In the window that pops up, click the "Browse..." button.

Navigate to qbrunner.bat and press "Open".

Back in the "Open With" dialog, check the "Always use..." box and click "OK".

Now, when you double click a .bas file in Windows Explorer your code will be interpreted by QB.

If you do not want the QB environment to open when the .BAS file is done, use keyword SYSTEM instead of END.

This file can be found HERE.