Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
What is the command to allow a user to input a filename then when they press enter it takes them to the right commandline. I dont want the one where you enter a variable and it has a choice and errorlevel to goto the commandline.
Thanks for any assistance you can give me.

By "the one where you enter a variable and it has a choice and errorlevel to goto the commandline" you're probably refering to the CHOICE cmd, right?
If you're on DOS (really DOS, not just command prompt for NT) or Win9x, my FAQ will help:
If you're on Windows 2000 or XP, use this command:
set /P FILENAME=Type filename:
That will display the message "Type filename:" and will wait for input. After user hits enter, the data goes to the variable specified on the left of the equals sign (in this case the variable %FILENAME%) and that's it (no loop back, it's already ended).
And finally, for Win NT 4-, use this:
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=> %temp%.\input.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>> %temp%.\input.com
echo @]yI?@xAp~sA`LZNt@x[}?MGI@]A?nsl@]}G@tLC?sBZ`LBL`_jN0xxxxx>> %temp%.\input.com
for /F "tokens=*" %%I in ('%temp%.\input.com') do set INPUT=%%I
del %temp%.\input.com-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br___________________________________________________________________________________

Heres one that i want for multiple uses:
maketrn multst07.trn /p="BANE.ini"
How do i write it if i want where "bane.ini" is to ask the user to input a "?.ini" then the line will execute?

o and it needs to search for the existing .ini in this path. C:/Program Files/Activision/Battlezone
Thank you for your help I really appreciate it.

What? I can't understand what you mean...
You wrote:
> How do i write it if i want where "bane.ini"
> is to ask the user to input a "?.ini" then the
> line will execute?What do you mean by that?
What I did describe is how to get user's input and save on an environment variable. I thought that was what you wanted. If it's not, please explain better and clearer.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

What I am doing is making a program that does many things. It auto creates a map for a game through a dos map editor. Instead of manually typing all of the dos commands I am making this series of batches to add to an installer. Each batch will do different things. The one in particular I am stuck on right now is I need to create a user input line where the user inputs a .ini filename and it adds the filename of that .ini, "Bane.ini" for example, into the Dos command line and executes it. This is the command line.
maketrn multst07.trn /p="BANE.ini"
the "BANE.ini" is the area where I need the inputed filename to be inserted.
Like say I wanted to use the "Mars.ini" Then I would enter "Mars" and it would create the Command line like this.
maketrn multst07.trn /p="Mars.ini"
and then Execute it.
Sorry I hope that helps.

Oh, it's much clearer now.
You can get user input with one of the scripts I posted above, according to the OS it's supposed to run. After getting the input saved on the variable %INPUT%, use it on the line:
maketrn multst07.trn /p="%input%.ini"
For instance, if the OS intended is WinXP, the 'global process' would be:
echo Type filename (without .ini extention)
set input=
:input
set /P input=
if "%input%"=="" goto input
maketrn multst07.trn /p="%input%.ini"In that sample, I've also included an error check for blank inputs - if user enters nothing, the scritp will loop back to the input getting.
You could also make something simpler: accept the filename as a variable of the batch script. User would invoke the script as this:
bscript.bat mars
And then, %1 would represent the first parameter "mars". The line for the map editor would become:
maketrn multst07.trn /p="%1.ini"
In that case, the filename would better not contain spaces, because a space would break it in two parameters (%1 and %2). That's not a problem with the other input methods (those that send input to variable). Oh, it's good to include some help information so user knows how to pass the parameter, and also some error checks.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_________________________________________________________

By the way, on my example:
bscript.bat mars
The "bscript.bat" is simply the batch script name, just an example.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |