I am creating some common doskey commands I use on a regular basis. I am trying to have multiple variables in the doskey macro and sometimes a variable will have spaces in it. I have tried quoting the variable values but it won't work. The only thing that does work is just adding more vars to the end of the macro string.
What I would like to do is: doskey keycmd=plink -l user -pw password $1 -batch $2 And then execute it as follows: c:> keycmd hostname "dir /p /users"
What doskey sees when executed though is: $1=hostname, $2="dir, and "dir isn't a command and /p and /users is completely dropped.
To get this to work I had to define it this way: doskey keycmd=plink -l user -pw password $1 -batch $2 $3 $4 And execute as follows: c:> keycmd hostname dir /p /users
Is there a way I can group "dir /p /users" into a single $2 variable? For doskey variable parameters you only get 9, $1..$9. Eventually I could run out on complicated commands. I tried single and double quotes to no avail...but single and/or double quotes seem to work everywhere else in Windows cmd command.
Is there a solution to this or am I just trying to do too much with doskey?