在命令提示符下使用echo创建文本文件

new*_*guy 5 command-line command command-prompt echo

我正在使用命令提示符中的echo在桌面上创建一个hello_world.txt,这是我的输入.

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

第一个代码工作,然后我尝试%userprofile%如果示例,我想将它提供给另一个用户.

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

不行.任何简单的echo命令行来创建文本文件?

Bin*_*man 7

你的命令应该是:

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


如果你之前放了任何东西它不起作用%userprofile%,因为它是一个完整的路径,所以C:\Users\%userprofile%\Desktop\hello_world.txt被替换为C:\Users\C:\Users\cromix\Desktop\hello_world.txt.