No silly vs Delete the internet? No silly. No need for the quotes. See ss Show 2 more comments. Once you have set your variable, you can then go about using it in the following fashion. Zitrax Please finish your sentence Also, I tested all of the above in a Windows 7 cmd. How is your response embellishing upon what's already been provided?
When I posted my answer it didn't really look like the original question had been answered. The original question is "How do you ask for user input and then turnaround and use it in another command? Plus when you search in Google for "how do you get user input from a batch file" this question is 2 in results so it needs the correct answer which I though that this forum was for. Why do we need the space?
What exactly goes on in the cmd that does not allow space? Joey I agree, the robvanderderwoude. Add a comment. Grimthorr 6, 5 5 gold badges 40 40 silver badges 52 52 bronze badges. Erik Philips Daniel Daniel 7 7 silver badges 16 16 bronze badges. Now it prints the quotes with the text, but there is no more strange behavior.
It's useful to use the quotes and include a space at the end as it makes the prompt on the command line nicer. Having the quotes makes it obvious that there is a space there in the batch file. Eamorr 9, 32 32 gold badges silver badges bronze badges.
This works for me in Windows 8. Edited to format code paragraphs properly. Timothy J. McGowan Timothy J. McGowan 1 1 silver badge 7 7 bronze badges. Carl H 1 1 silver badge 12 12 bronze badges. Anisha Gupta Anisha Gupta 81 1 1 silver badge 1 1 bronze badge. Why do you start with :start?
For example, he might use a :end as well, that causes things like variable cleanup to happen, or to call a popd , or something like that. There are two possibilities. ECHO "remember to run this as admin. Werdna Werdna 51 1 1 silver badge 1 1 bronze badge. Failing the below code you could add this but the code at the bottom should work. Another much simpler way to do this in two lines, without using the IF statement is this:.
This tool allows users to select one item from a list of choices and returns the index of the selected choice. In this example, 1 will be returned when y is pressed, and 2 will be returned when n is pressed.
EDIT: You are kind of on track, but you just were using the wrong commands. Another way you could implement my fix is this:.
It is full of sooo much information. This also removes any id10t user errors, meaning anything the user could do to try to break it or use it wrong. That way, you catch if they don't enter either Yes or No and catch if they enter any variation of Yes or No. It's hard to get more simple than that, there's only one command-flag not four, it doesn't depend on Command Extensions and there's little question of version-compatibility.
In terms of validation, well, the user has to put in the right parameter. If they don't, it's wrong. Simple as that. Echo it back to confirm with a pause and the user can control-break out of it. Could more time be spent arguing the pros and cons of different approaches? Is that wise? Probably not. Certainly not. Layout: fixed fluid.
First Prev Next. My vote of 1 Member Aug Member How do i do this in DOS? This syntax only works in Windows command shell. My Vote of 5 David A. My vote registered before I had a chance to comment it.
Sometimes, the simplest subjects make the best articles. This is a case in point. Moreover, seven years in the future, the material is as relevant as it was when it was published. Reason for my vote of 5 quick answer, some time when working
0コメント