我尝试使用批处理脚本创建如下文件:
echo ping %ip% -t -l %psize1% >%n%_%psize1%.bat
%n%
(姓名)在其他地区正确陈述%psize1%
(包装尺寸)%n%
为test
且%psize1%
为10
,则该文件应如test_10.bat
然而,它会创建_10.bat
文件并完全保留%n%
语句。
@echo off
mode 128.64
title DOS Creator 2.0
color 07
:wrapper
cls
echo --------------------------------------------------------
echo Welcome To Ping check By Raoul
echo --------------------------------------------------------
echo.
pause
:menu
cls
echo -----------------------------------------
echo - 1. Guide
echo - 2. Target Information
echo - 3. Parameters
echo - 4. Exectution Parameters
echo - 5. Final Check
echo - 6. Exit
echo -----------------------------------------
set /p option="Option : "
If "%option%" == "" (
echo PLASE STATE ANNY OF THE ABOVE NAMED OPTIONS
pause
Goto :menu
) else if "%option%" == "1" (
goto :Guide
) else if "%option%" == "2" (
goto :info
) else if "%option%" == "3" (
goto :end
)
:Guide
cls
echo this is still WIP
pause
goto :menu
:info
cls
set /p ip=Ip Host:
set /p fname=File Name:
pause
cls
echo The Following has been stated:
echo IP:----------------"%ip%"
echo File Name:---------"%fname%"
echo.
set /p option="Is this correct? (y/n) : "
if "%option%" == "y" goto :Parameters
goto :Target
:Parameters
cls
echo.
set /p psize1=Package size file 1:
echo.
set /p option="Ready to create files? (y/n) : "
if "%option%" == "y" Goto :Creator
goto :Parameters
:Creator
echo ping %ip% -t -l %psize1% >%n% %psize1%.bat
cls
echo --------------------------------------------------------
echo The following files have been created with info:
echo Target IP -"%ip%"- Package size for file 1 -%psize1%-
echo --------------------------------------------------------
echo.
pause
答案 0 :(得分:0)
你永远不会设置变量n,所以%n%扩展为空字符串,当然...... - aschipfl
Anwser是检查变量,如果它们是正确的并且已说明。在我的情况下,我忘了将n改为Fname。