Batch file 创建一个.bat文件,该文件在命令提示符下接受用户输入,并将其保存到文本文件中
我需要创建一个.bat文件,该文件在命令提示符中接受用户输入,并将其保存到文本文件中 在命令提示符中,它希望:Batch file 创建一个.bat文件,该文件在命令提示符下接受用户输入,并将其保存到文本文件中,batch-file,input,terminal,cmd,Batch File,Input,Terminal,Cmd,我需要创建一个.bat文件,该文件在命令提示符中接受用户输入,并将其保存到文本文件中 在命令提示符中,它希望: What is the path: "C:\Users\21241\Desktop\test" Number of times to run: "7" 在文本文件中,它看起来像: User_input_Path: C:\Users\21241\Desktop\test Num_run_time: 7 不管怎样,你想这么做吗 @echo off&cls set /p $pat
What is the path: "C:\Users\21241\Desktop\test"
Number of times to run: "7"
在文本文件中,它看起来像:
User_input_Path: C:\Users\21241\Desktop\test
Num_run_time: 7
不管怎样,你想这么做吗
@echo off&cls
set /p $path=What is the path:
set /p $num=Number of times to run:
(echo User_input_Path: %$path%
echo Num_run_time: %$num%)>your_text_file.txt
不在windows上,因此无法测试,但这应该可以工作
不在windows上,因此无法测试,但这应该可以工作
不在windows上,因此无法测试,但这应该可以工作
不在windows上,因此无法测试,但这应该可以工作。假设您只想运行一次:
@echo off
SET /P Path="What is the path: "
SET /P Num="Number of times to run: "
ECHO What is the path: %Path% > sample.txt
ECHO Number of times to run: %Num% > sample.txt
但是,如果希望“运行次数”是用户输入路径的次数,则:
@echo off
SET /P Num="Number of times to run: "
SET Count=1
IF %Num% NEQ %Count% (
SET /P Path="What is the path: "
ECHO What is the path: %Path% > sample.txt
SET /A Count=Count+1
) ELSE exit
假设您只想运行一次:
@echo off
SET /P Path="What is the path: "
SET /P Num="Number of times to run: "
ECHO What is the path: %Path% > sample.txt
ECHO Number of times to run: %Num% > sample.txt
但是,如果希望“运行次数”是用户输入路径的次数,则:
@echo off
SET /P Num="Number of times to run: "
SET Count=1
IF %Num% NEQ %Count% (
SET /P Path="What is the path: "
ECHO What is the path: %Path% > sample.txt
SET /A Count=Count+1
) ELSE exit
假设您只想运行一次:
@echo off
SET /P Path="What is the path: "
SET /P Num="Number of times to run: "
ECHO What is the path: %Path% > sample.txt
ECHO Number of times to run: %Num% > sample.txt
但是,如果希望“运行次数”是用户输入路径的次数,则:
@echo off
SET /P Num="Number of times to run: "
SET Count=1
IF %Num% NEQ %Count% (
SET /P Path="What is the path: "
ECHO What is the path: %Path% > sample.txt
SET /A Count=Count+1
) ELSE exit
假设您只想运行一次:
@echo off
SET /P Path="What is the path: "
SET /P Num="Number of times to run: "
ECHO What is the path: %Path% > sample.txt
ECHO Number of times to run: %Num% > sample.txt
但是,如果希望“运行次数”是用户输入路径的次数,则:
@echo off
SET /P Num="Number of times to run: "
SET Count=1
IF %Num% NEQ %Count% (
SET /P Path="What is the path: "
ECHO What is the path: %Path% > sample.txt
SET /A Count=Count+1
) ELSE exit
请不要将path
用作变量名。它是一个系统变量,更改它可能(也可能会)导致失败。请不要将path
用作变量名。它是一个系统变量,更改它可能(也可能会)导致失败。请不要将path
用作变量名。它是一个系统变量,更改它可能(也可能会)导致失败。请不要将path
用作变量名。它是一个系统变量,更改它可能(也可能会)导致失败。