使用批处理创建文件不会写%(任何文本)

时间:2016-06-15 09:16:53

标签: windows file batch-file cmd

我创建了一个批处理文件,它应该创建另一个批处理文件... (%passwordw%在我的代码中设置如上,但因为它大约有300行,所以我没有浪费你的时间,,,)

echo @title .  > "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo @echo off >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo set one=%1 >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo set filepathname=%~f0 >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo set filenameofcaller=%2 >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo if %one%== calling goto :callingpassword >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo start C:\Users\%USERNAME%\Documents\Notes\Fivos >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo @echo off >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo exit >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo :callingpassword >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"
echo call %filenameofcaller% 12 >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"

但不是接收我所说的"批处理,我收到了这个

@title .  
@echo off 
set one= 
set filepathname=C:\Users\1\Desktop\Launcher.bat 
set filenameofcaller= 
if == calling goto :callingpassword 
start C:\Users\1\Documents\Notes\Fivos 
@echo off 
exit 
:callingpassword 
call  12 

我认为%i有什么问题,导致它的原因以及如何解决这个问题? 我不知道从哪里开始找到这个问题的位置,因为我在bash中很新...

感谢您的时间, 菲沃斯

1 个答案:

答案 0 :(得分:1)

您应该使用%%代替%

例如,第三行应如下所示:

echo set one=%%1 >> "C:\Users\%USERNAME%\Desktop\%passwordw%.bat"