Sacred Posted February 23, 2010 Share Posted February 23, 2010 Does anybody know how to use user-input to set a variable in MS-DOS? To make VAR1 = 12 for example, or a string of letters. I used to know how, but I forgot. Can anyone help me out here?I know in C++ it is cin >> VAR1;In MS-DOS it's like set /p VAR1 =Or something like that, but it doesn't seem to work.I wanna use that data to compare using an IF statement, that part isn't hard, just the user-input part is what I need to know.All Help is greatly appreciated ~Sacred Link to comment Share on other sites More sharing options...
Synook Posted February 23, 2010 Share Posted February 23, 2010 It's like you wrote, but with a space before the equals sign. Note that this doesn't actually take the value from the standard input - piping won't work.Edit: Ah, did I actually write that? I meant without a space. Link to comment Share on other sites More sharing options...
Sacred Posted February 23, 2010 Author Share Posted February 23, 2010 All I know is, is that I used to be able to ask for passwords in batch files so that if a variable equaled that value I preset, it would GOTO wherever I chose it to go. I know there is a way, I did it before. It's like:---------------------------------------------------------------------set /p Password = [should Be User-Input Here]IF(%password%)=="1337" GOTO PASSWORDACCEPTED--------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2010 Share Posted February 23, 2010 SET /P variable=[promptString]This command will display an optional promptString where the user can type in a string and press Enter. The typed string will then be stored in the specified environment variable variable. Link to comment Share on other sites More sharing options...
Sacred Posted February 24, 2010 Author Share Posted February 24, 2010 Nevermind, figured it out. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.