| 1. |
Solve : Parameters at command line question? |
|
Answer» I know I can take parameters at command line LIKE: fireballs, you had on % sign too many. To set Pone to the value of the first parameter you would use It works either way for me. you could have: Code: [Select] if %%1=="-password" GOTO password if %%1="-username" goto username exit :username if not %%2=="My Username" (exit) else ( if not %%4=="My Password" exit ) goto code :password if not %%2=="My Password" (exit) else ( if not %%4=="My Username" exit ) goto code is that what your looking for? EDIT: i think we had the same idea, you posted as i was writing a response. FBThat's the one, thought there might have been an actual command. Thanks.While I was posting a reply, I saw the red "While you were typing a new reply has been posted" warning. If you think about it logically, you only have 2 possibilities for the parameter sequence (a) %1 -user %2 username %3 -password %4 password (b) %1 -password %2 password %3 -user %4 username So if you look at %1 you will find out all you need to know Code: [Select]if "%1"=="-user" ( set username=%2 set password=%4 ) else ( set password=%2 set username=%4 ) I suppose my thinking was that using %1 - %9 can be limiting, mainly due to the amount of parameters that can be passed. You can pass any number of parameters, you aren't limited to 9, as you will see if you study the SHIFT command. Also, the %* parameter expands to a string made up of ***all*** of the parameters passed. I see, so the SHIFT command will keep shifting through parameters, so I could have a large amount of them. Nice one. |
|