如何编写一个Windowsbatch file

我在位置“ C:\Users\me\Desktop ”中有一个可执行的“ myfile.exe ”文件我想通过批处理在C:\Users\me\Desktop上执行命令“ myfile.exe <firstArg> <secondArg> ”文件,

在命令行中:

 C:\Users\me\Desktop>myfile.exe <firstArg> <secondArg> 

如何在windows中编写上述命令的批处理脚本

使用参数变量batchFile.bat的内容是:

 @echo off C:\Users\me\Desktop\myfile.exe %1 %2 

或固定参数:

 @echo off C:\Users\me\Desktop\myfile.exe <firstArg> <secondArg> 

只需将您正在执行的确切命令从命令行添加到.bat文件即可。 如有必要,先更改工作目录。

 cd C:\Users\me\Desktop myfile.exe <firstArg> <secondArg> 

你的批处理文件:

 C:\Users\me\Desktop\myfile.exe %1 %2 

然后你可以调用你的批处理文件:

 mybatchfile.bat <firstArg> <secondArg> 

此外,您可以使用%*传递所有参数,而不是指定每个参数。