Related:
- Comando attrib - r-h-s /s /d *.*
- Windows 10 iso file download 64-bit - Download - Windows
- Kmspico zip file download - Download - Other
- Tiny 11 iso file download - Download - Windows
- Ping batch file output to text - Guide
- Kerbal space program free download - Download - Simulation
6 responses
the problem is i have to edit the batch file each time i change the contentes of the folder. i am looking for a way to make a batch file that can just be droped into any folder of links and work with out editing it. the batch file needs to do several tasks 1st it needs to make a menu with poplulated with all the links in the folder. 2nd it needs to be able to launch those programs after the user picks what one to run. i am haveing problems accessing the variables that this bit of code produces
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk /b') do (
set /a n+=1
set v!n!=%%a
)
set v
i can access the values by %v1% but i am unable to figure out how to access the values with an adtional variable.
i have tried %vc% as well as %v!c!% and many other combanations i figure i can set c to the program number that corasponds to the link i want run. The other problem i have with the above code is it does not list in order it seems to list out v1 v10 v11 v12 v13 v14 v2 ....
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk /b') do (
set /a n+=1
set v!n!=%%a
)
set v
i can access the values by %v1% but i am unable to figure out how to access the values with an adtional variable.
i have tried %vc% as well as %v!c!% and many other combanations i figure i can set c to the program number that corasponds to the link i want run. The other problem i have with the above code is it does not list in order it seems to list out v1 v10 v11 v12 v13 v14 v2 ....
I guess you should be able to map your programmable keys directly to games' exe. That should serve the purpose.
yeah to do that right click on the game and do make a shortcut withc is way simpler than making a batch file. But if you want a batch file this is what you have to type for example
@echo off
echo Age of Empires 3
echo starting
start C:\ProgramFiles\microsoftgames\ageofempires3\age3.exe
echo started
@echo off
echo Age of Empires 3
echo starting
start C:\ProgramFiles\microsoftgames\ageofempires3\age3.exe
echo started
Putting %CD%\ before the path to your programs, and you could use a lot of IF NOT EXIST commands to try and create a makeshift menu..
i'd give an example, but i'm working on my own batch problem..
I've got a setup that needs to execute from a directory in a CD, but it can't be run from DOS, so i need a batch file to start a link to that setup, but the batch treats it as the Setup.exe, not the link, and tries to run it in DOS again..
i'd give an example, but i'm working on my own batch problem..
I've got a setup that needs to execute from a directory in a CD, but it can't be run from DOS, so i need a batch file to start a link to that setup, but the batch treats it as the Setup.exe, not the link, and tries to run it in DOS again..
Didn't find the answer you are looking for?
Ask a question
This is the easiest way using a input choice
@echo off
:start
cls
@Echo Game 1 Age of Empires III
@Echo Game 2 Dungeon Siege
@Echo Game 3 Dungeon Siege Legends of Aranna
@Echo Game 4 Etherlords II
set /p userinp=choose a number(1-6):
set userinp=%userinp:~0,1%
if "%userinp%"=="1" goto 1
if "%userinp%"=="2" goto 2
if "%userinp%"=="3" goto 3
if "%userinp%"=="4" goto 4
echo invalid choice
goto start
:1
(start Age of Empires III )
goto end
:2
(start Dungeon Siege )
goto end
:3
(start Dungeon Siege Legends of Aranna)
goto end
:4
(start Etherlords II)
goto end
:end
@echo off
:start
cls
@Echo Game 1 Age of Empires III
@Echo Game 2 Dungeon Siege
@Echo Game 3 Dungeon Siege Legends of Aranna
@Echo Game 4 Etherlords II
set /p userinp=choose a number(1-6):
set userinp=%userinp:~0,1%
if "%userinp%"=="1" goto 1
if "%userinp%"=="2" goto 2
if "%userinp%"=="3" goto 3
if "%userinp%"=="4" goto 4
echo invalid choice
goto start
:1
(start Age of Empires III )
goto end
:2
(start Dungeon Siege )
goto end
:3
(start Dungeon Siege Legends of Aranna)
goto end
:4
(start Etherlords II)
goto end
:end
This is what worked for me. It lists all the shortcut files in the folder. You choose an option and the game runs.
The .bat file must however be in the same folder as all of your shortcuts for it to work as it is.
@echo off
:menu
cls
echo.
echo. GAME SETUP AND SELECTION MENU
echo.
echo. ( Q quits )
echo.
cd /d %~dp0
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk *.*.lnk /b') do (
set /a n+=1
set game !n!=%%a
)
set game
echo.
set /p Choice= Please select a game:
echo.
IF /I '%Choice%'=='1' GOTO :1
IF /I '%Choice%'=='2' GOTO :2
IF /I '%Choice%'=='3' GOTO :3
IF /I '%Choice%'=='4' GOTO :4
IF /I '%Choice%'=='5' GOTO :5
IF /I '%Choice%'=='q' GOTO :end
echo.
echo. Computer says no
echo.
pause
goto :menu
:1
call %game 1%
goto :menu
:2
call %game 2%
goto :end
:3
call %game 3%
goto :menu
:4
call %game 4%
goto :menu
:5
call %game 5%
goto :menu
:end
The .bat file must however be in the same folder as all of your shortcuts for it to work as it is.
@echo off
:menu
cls
echo.
echo. GAME SETUP AND SELECTION MENU
echo.
echo. ( Q quits )
echo.
cd /d %~dp0
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk *.*.lnk /b') do (
set /a n+=1
set game !n!=%%a
)
set game
echo.
set /p Choice= Please select a game:
echo.
IF /I '%Choice%'=='1' GOTO :1
IF /I '%Choice%'=='2' GOTO :2
IF /I '%Choice%'=='3' GOTO :3
IF /I '%Choice%'=='4' GOTO :4
IF /I '%Choice%'=='5' GOTO :5
IF /I '%Choice%'=='q' GOTO :end
echo.
echo. Computer says no
echo.
pause
goto :menu
:1
call %game 1%
goto :menu
:2
call %game 2%
goto :end
:3
call %game 3%
goto :menu
:4
call %game 4%
goto :menu
:5
call %game 5%
goto :menu
:end
Just add more options to your menu ie.
add 100 of these:....
IF /I '%Choice%'=='x' GOTO :x
and 100 of these:....
:x
call %game x%
goto :menu
changing x in each one.... 12,3,4 and so on
then your menu will have 100 possible entries but it will still only list the shortcut files in the folder and if you were to copy more *.lnk files in there they would automatically show up. unless I have misunderstood your question. you should not need to edit the file to ad more items to the menu or to take them off.
add 100 of these:....
IF /I '%Choice%'=='x' GOTO :x
and 100 of these:....
:x
call %game x%
goto :menu
changing x in each one.... 12,3,4 and so on
then your menu will have 100 possible entries but it will still only list the shortcut files in the folder and if you were to copy more *.lnk files in there they would automatically show up. unless I have misunderstood your question. you should not need to edit the file to ad more items to the menu or to take them off.
Ok that one is kinda #^& how about this one. Copy and paste as is int a .bat and run from your .lnk folder
@echo off
:menu
cls
echo. GAME SETUP AND SELECTION MENU
echo. ( Q quits )
echo.__________________________________________________
cd /d %~dp0
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk *.*.lnk /b') do (
set /a n+=1
set game !n!=%%a
)
set game
echo.
set /p Choice= Please select a game:
echo.
IF /I '%Choice%'=='1' call %game 1%
IF /I '%Choice%'=='2' call %game 2%
IF /I '%Choice%'=='3' call %game 3%
IF /I '%Choice%'=='4' call %game 4%
IF /I '%Choice%'=='5' call %game 5%
IF /I '%Choice%'=='1' call %game 6%
IF /I '%Choice%'=='1' call %game 7%
IF /I '%Choice%'=='1' call %game 8%
IF /I '%Choice%'=='1' call %game 9%
IF /I '%Choice%'=='1' call %game 10%
IF /I '%Choice%'=='1' call %game 11%
IF /I '%Choice%'=='1' call %game 12%
IF /I '%Choice%'=='1' call %game 13%
IF /I '%Choice%'=='1' call %game 14%
IF /I '%Choice%'=='1' call %game 15%
IF /I '%Choice%'=='1' call %game 16%
IF /I '%Choice%'=='1' call %game 17%
IF /I '%Choice%'=='1' call %game 18%
IF /I '%Choice%'=='1' call %game 19%
IF /I '%Choice%'=='1' call %game 20%
IF /I '%Choice%'=='1' call %game 22%
IF /I '%Choice%'=='1' call %game 23%
IF /I '%Choice%'=='1' call %game 24%
IF /I '%Choice%'=='1' call %game 25%
IF /I '%Choice%'=='1' call %game 26%
IF /I '%Choice%'=='1' call %game 27%
IF /I '%Choice%'=='1' call %game 28%
IF /I '%Choice%'=='1' call %game 29%
IF /I '%Choice%'=='1' call %game 30%
IF /I '%Choice%'=='q' GOTO :eof
echo.
echo. Computer says no
echo.
pause
goto :menu
@echo off
:menu
cls
echo. GAME SETUP AND SELECTION MENU
echo. ( Q quits )
echo.__________________________________________________
cd /d %~dp0
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir *.lnk *.*.lnk /b') do (
set /a n+=1
set game !n!=%%a
)
set game
echo.
set /p Choice= Please select a game:
echo.
IF /I '%Choice%'=='1' call %game 1%
IF /I '%Choice%'=='2' call %game 2%
IF /I '%Choice%'=='3' call %game 3%
IF /I '%Choice%'=='4' call %game 4%
IF /I '%Choice%'=='5' call %game 5%
IF /I '%Choice%'=='1' call %game 6%
IF /I '%Choice%'=='1' call %game 7%
IF /I '%Choice%'=='1' call %game 8%
IF /I '%Choice%'=='1' call %game 9%
IF /I '%Choice%'=='1' call %game 10%
IF /I '%Choice%'=='1' call %game 11%
IF /I '%Choice%'=='1' call %game 12%
IF /I '%Choice%'=='1' call %game 13%
IF /I '%Choice%'=='1' call %game 14%
IF /I '%Choice%'=='1' call %game 15%
IF /I '%Choice%'=='1' call %game 16%
IF /I '%Choice%'=='1' call %game 17%
IF /I '%Choice%'=='1' call %game 18%
IF /I '%Choice%'=='1' call %game 19%
IF /I '%Choice%'=='1' call %game 20%
IF /I '%Choice%'=='1' call %game 22%
IF /I '%Choice%'=='1' call %game 23%
IF /I '%Choice%'=='1' call %game 24%
IF /I '%Choice%'=='1' call %game 25%
IF /I '%Choice%'=='1' call %game 26%
IF /I '%Choice%'=='1' call %game 27%
IF /I '%Choice%'=='1' call %game 28%
IF /I '%Choice%'=='1' call %game 29%
IF /I '%Choice%'=='1' call %game 30%
IF /I '%Choice%'=='q' GOTO :eof
echo.
echo. Computer says no
echo.
pause
goto :menu
May 15, 2009 at 05:11 AM
I think you just missed the working configuration, !v%c%! should work, as %c% always gets expanded BEFORE the line is executed, and then !v1! will be executed (assuming c=1).
Regarding listing in order, this should allow you to do a FOR /L to run through the list.
But it would probably be easier to just use an ECHO inside the FOR /F loop you already have to find the programs :-)
I think this does what you want: