windows 如何创建可执行的命令提示脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13975733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:09:10  来源:igfitidea点击:

How to create an executable command prompt script

windowscommand-lineexecutable

提问by user1301428

I usually perform actions in the 7zip command line program. I was thinking about creating a small script to do everything automatically, but I have never written any Windows shell script before and therefore don't even know where to begin.

我通常在 7zip 命令行程序中执行操作。我正在考虑创建一个小脚本来自动执行所有操作,但我之前从未编写过任何 Windows shell 脚本,因此甚至不知道从哪里开始。

I would like to make an executable script file which, when a user double-clicks on it, will call the 7zip command line and perform some actions.

我想制作一个可执行脚本文件,当用户双击它时,将调用 7zip 命令行并执行一些操作。

First of all, is this possible? And if it is, what is the best way to do this?

首先,这可能吗?如果是,那么最好的方法是什么?

回答by Bali C

You can create a batch script to do this.

您可以创建批处理脚本来执行此操作。

It's basically command line commands that run one after another so you don't have to keep typing them in :)

它基本上是一个接一个运行的命令行命令,因此您不必继续输入它们:)

Put the commands you would normally use for 7zip in a notepad file and save it with the extension .bat, then run it.

将通常用于 7zip 的命令放在记事本文件中,并使用扩展名保存.bat,然后运行它。

7z blah blah params
7z more params and args

All your commands will be executed automatically when the previous one finishes.

上一个命令完成后,您的所有命令都会自动执行。

There are other programming languages you could do this in (or even VBScript) but batch would be perfectly suited to this, and you don't need to install anything extra.

您可以使用其他编程语言(甚至 VBScript)执行此操作,但批处理非常适合此操作,并且您无需安装任何额外内容。

回答by jaypeagi

Batch files can run a series of command line commands. Simply create a text file and name it with the .batextension.

批处理文件可以运行一系列命令行命令。只需创建一个文本文件并使用.bat扩展名命名它。

There are plenty of resources on the internet which will provide you with help.

互联网上有很多资源可以为您提供帮助。