DOS command line question..
#1
All to be run in Windows NT:
C'mon then you IT guys. My DOS days are long behind me now, but how do I do this?
In a batch file I want to prompt for an input and then pass that input to a variable. For example
"What is your name?"
You would input your name and that would be passed to a variable user_name
Any thoughts?
And I don't want to use Kix to achieve this!
Cheers,
Simon
C'mon then you IT guys. My DOS days are long behind me now, but how do I do this?
In a batch file I want to prompt for an input and then pass that input to a variable. For example
"What is your name?"
You would input your name and that would be passed to a variable user_name
Any thoughts?
And I don't want to use Kix to achieve this!
Cheers,
Simon
#2
Have done this before with a noddy C program that asks the user the question, which it pulls from a text file, then sets the env variable on exit.
Not sure how to do it just in NT commands - think I got bored of trying and just did it in C.
Simon.
Not sure how to do it just in NT commands - think I got bored of trying and just did it in C.
Simon.
#3
you can do it, but it won't be pretty. You need to ask the question then add each character to a string (which you set to be blank at the start) after checking that it is not return.
You can use a nested If then append statement to do this. Not sure of the syntax but I'm sure someone will have it in seconds
You can use a nested If then append statement to do this. Not sure of the syntax but I'm sure someone will have it in seconds
#6
Dont know if I'm missing some of your requirements, but try this:
Create a file (Scumbag.bat) in notepad (make sure it as saved under all files not text, otherwise you'll get that sodding .txt extension)
Make a single line entry of :
echo %1 %2
Now invoke the file from DOS as:
Scumbag X Y
This should now take the two values X and Y and feed them into the %1 and %2 variables, and you'll get the echo you require.
You can do this for as many variables as you want, and obviously you'll be wanting to do something more interesting than printing them back to the screen
[and before you ask, God knows where I dragged that from]
Hope this helps
SB
Create a file (Scumbag.bat) in notepad (make sure it as saved under all files not text, otherwise you'll get that sodding .txt extension)
Make a single line entry of :
echo %1 %2
Now invoke the file from DOS as:
Scumbag X Y
This should now take the two values X and Y and feed them into the %1 and %2 variables, and you'll get the echo you require.
You can do this for as many variables as you want, and obviously you'll be wanting to do something more interesting than printing them back to the screen
[and before you ask, God knows where I dragged that from]
Hope this helps
SB
Trending Topics
#8
Scumbag -- if you already have a file that you'd like to append to you can do something like:
echo %1>temp.txt
copy already_invoked_file.txt+temp.txt already_invoked_file.txt
but I think this is diverging from the requirement.
I was going to suggest use of the scankey command, which returns the ASCII value of the entered character into the %errorlevel% variable, but I found this webpage:
echo %1>temp.txt
copy already_invoked_file.txt+temp.txt already_invoked_file.txt
but I think this is diverging from the requirement.
I was going to suggest use of the scankey command, which returns the ASCII value of the entered character into the %errorlevel% variable, but I found this webpage:
Thread
Thread Starter
Forum
Replies
Last Post
Pro-Line Motorsport
Car Parts For Sale
2
29 September 2015 07:36 PM