Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.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
Windows 如何在命令行.cmd中使用参数_Windows_For Loop_Batch File_Cmd_Command Line Arguments - Fatal编程技术网

Windows 如何在命令行.cmd中使用参数

Windows 如何在命令行.cmd中使用参数,windows,for-loop,batch-file,cmd,command-line-arguments,Windows,For Loop,Batch File,Cmd,Command Line Arguments,这是我第一次编写.cmd文件 我需要用一些命令解密一个文件。。让我们用一个简单的例子。 我所需要的就是如何让用户在双击.cmd文件后输入参数,以及如何在cmd文件中使用参数 假设我需要用户在双击.cmd文件后输入他的名字: @echo off &setlocal &cls echo.hello set /p "name=please enter your name: " echo.how are u %name% set /p "fpath=please enter the pa

这是我第一次编写.cmd文件

我需要用一些命令解密一个文件。。让我们用一个简单的例子。 我所需要的就是如何让用户在双击.cmd文件后输入参数,以及如何在cmd文件中使用参数

假设我需要用户在双击.cmd文件后输入他的名字:

@echo off &setlocal &cls
echo.hello
set /p "name=please enter your name: "
echo.how are u %name%
set /p "fpath=please enter the path that you want ... : "
echo.the file has been succefully decrypted in %fpath%
endlocal
你好
请输入您的姓名://此处用户应输入其姓名,例如Peter
u Peter//这里的文件使用arg0并等待用户输入他的名字,然后程序将继续
请输入所需的路径…://在此,用户输入要保存输出文件的路径…
该文件已在//路径中成功解密

因此,我需要的代码必须类似于:

echo hello
wait()//till the user enters his name
echo hello arg0
echo please enter the path that you want ... 
echo the file has been succefully decrypted in arg1

我认为不可能从键盘接收输入并将其用作批处理文件中的变量

为什么不试试C++控制台应用程序?

试试这个:

set /p name=enter your name:
echo how are you %name% ?

将其放入.cmd文件中:

@echo off &setlocal &cls
echo.hello
set /p "name=please enter your name: "
echo.how are u %name%
set /p "fpath=please enter the path that you want ... : "
echo.the file has been succefully decrypted in %fpath%
endlocal

有可能你可以尝试上面的两个答案,它将工作!!