如何指定 %digit 值

How to specify %digit values

我对 bat 文件一无所知,我刚从供应商那里收到一个批处理文件,希望我替换值和 运行 批处理。

@ECHO OFF
REM %1 is the name of the machine and SQL instance
REM %2 is the name of the database
REM %3 is the name of the machine 2

我知道名字,但我不知道如何告诉 bat 文件它们是什么

更新:经过编辑和评论后,我认为您正在寻找 this information

没有实际代码很难提供帮助,但我假设您发布的是对参数值的评论。

因此您将调用批处理文件并提供 as arguments

theScript.bat "name of machine and sql instance" "database name" "second machine"

然后脚本本身将按照描述的方式评估参数,例如here

%1 %2 %3 是批处理文件参数。要为它们设置值,您可以创建另一个单行批处理文件,它将使用您想要的参数调用第一个想要的:

@call database.bat machine database_name machine2

你不应该替换任何东西。那些 REM 行只是告诉你,需要什么参数。
当机器的名字和SQL实例是类似Server1-inst05,数据库的名字是VendorsBase,机器2的名字是Workstation,你应该执行批处理文件(我们称它为 vendor.bat)如下所示:

vendor.bat Server1-inst05 VendorsBase Workstation

vendor.bat 在内部将这三个参数引用为 %1%2%3

(这与 npocmaka 和 BNT 提供的信息完全相同;只是技术性较低)