Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 创建一个.bat文件,该文件在命令提示符下接受用户输入,并将其保存到文本文件中_Batch File_Input_Terminal_Cmd - Fatal编程技术网

Batch file 创建一个.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

我需要创建一个.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 $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
用作变量名。它是一个系统变量,更改它可能(也可能会)导致失败。