Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey .. .i've been wondering is there anyway to make a .bat file to run programs on a usb?.. so that it will either ask you to input a name to run the software.. or it will give u a list to chose from.?..

echo off
setlocal enabledelayedexpansion
set pathN=c
pushd %pathn%:\
::above, unit letter
set /a ct=0
for %%a in (%pathn%:\*.exe,%pathn%:\*.com,%pathn%:\*.bat,%pathn%:\*.cmd) do (
echo %%~nxa
)
echo.
set /p ThisApp=Launch application (name):
"%ThisApp%"
popd---------------------
I need help too.
The above code works but I fail in attribute a NUMBER for each output of FOR command in order to launch application by typing its number, not its name.
I do like this:set /a ct=0
for %%a in (*.exe, *.com) do (
set /a ct=!ct!+1
echo !ct! - %%a
set comm!ct!="%%a"
)
set /p number=Run this application (number):
set ThisApp=comm%number%
%ThisApp%
I cant get ThisApp variable expressing its real content. It always reply with its literal value (comm1, comm2..).Can anybody help me.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |