Bat windows input parameter




















Didn't any of these answers work? If not, did you find a solution? If you did, it would be helpful if you posted it here as a self-answer. Show 1 more comment. Active Oldest Votes. Improve this answer. Instantsoup Instantsoup I've tried several different ways, and haven't been able to find a way to do this, outside of writing a little C program to take the input, and assign it to an EnvVar, but that's cheating! LarryF check out stackoverflow.

Note the added nicety of the space at the end of "Enter ID: ". Gives a sweet little space between the prompt and the user answer. Delete the internet? 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. In the batch script, I am printing the passed parameters on the console using the echo. When an argument is used to supply a filename then the following extended syntax can be applied. Skip to content.

In batch script, it is also possible to define a variable to hold a numeric value. All of the arithmetic operators work in batch files. The following example shows arithmetic operators can be used in batch files. In any programming language, there is an option to mark variables as having some sort of scope, i.

Normally, variable having a global scope can be accessed anywhere from a program whereas local scoped variables have a defined boundary in which they can be accessed.

I know of several occasions where these seemingly useless "features" proved very handy. Keep in mind, though, that these "features" may vary with the operating systems used.

Windows and XP add even more options. Do note, however, that labels are case sensitive, so you may not want to use this technique for "string type" arguments.



0コメント

  • 1000 / 1000