Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create text file using echo in command prompt

I'm creating a hello_world.txt in the desktop using echo in command prompt and this is my input.

echo hello world > C:\Users\user\Desktop\hello_world.txt

The first code works, then I try %userprofile% if example, I want to give it to another user.

echo hello world > C:\Users\%userprofile%\Desktop\hello_world.txt

Doesn't work. Any simple echo command line to create text file?

like image 461
2 revs, 2 users 98% Avatar asked Jun 10 '15 12:06

2 revs, 2 users 98%


1 Answers

Your command should be:

echo hello world > %userprofile%\Desktop\hello_world.txt


It doesn't work if you put anything before %userprofile%, because it's a full path, so C:\Users\%userprofile%\Desktop\hello_world.txt gets substituted to C:\Users\C:\Users\cromix\Desktop\hello_world.txt.

like image 101
Binkan Salaryman Avatar answered Sep 18 '22 20:09

Binkan Salaryman