cmd - How can the batch file use the username? -
i want make batch file make this:
set /p username=username: echo %username% > c:/users/%username%/desktop/extramitico/ud1.txt
and says:
the system can not find path specified
why?? please help!
much depends on input, , mentioned, username
variable established system , hence poor, if logical, choice.
let's presume use
set /p name=username: echo %name% > c:/users/%name%/desktop/extramitico/ud1.txt
you message if string input name
contains illegal characters *
or :
.
you message if directory c:/users\%name%\desktop\extramitico\
not exist - , note directory-separator \
, not /
- /
used switches.
and message if name input contains spaces or commas , other characters.
so - try
set /p name=username: md "c:\users\%name%\desktop\extramitico" 2>nul echo %name% > "c:\users\%name%\desktop\extramitico\ud1.txt"
where "quoting string"
gets on spaces etc. in input (but not illegal characters). 2>nul
suppresses 'directory existsmessage from
md`.
and maybe forget set /p
statement, , use system-set variable username
. depends on quite want do.
Comments
Post a Comment