Create a text file using echo on the command line
I am creating hello_world.txt on the desktop using echo on the command line and this is my input.
echo hello world > C:\Users\user\Desktop\hello_world.txt
The first code works, then I try% userprofile% if for example I want to pass it to another user.
echo hello world > C:\Users\%userprofile%\Desktop\hello_world.txt
Does not work. Any simple echo command line to create a text file?
source to share
Your command should be:
echo hello world > %userprofile%\Desktop\hello_world.txt
It doesn't work if you put anything in front of it %userprofile%
, because it is a full path, so it C:\Users\%userprofile%\Desktop\hello_world.txt
is replaced with C:\Users\C:\Users\cromix\Desktop\hello_world.txt
.
source to share