Aileen Gregg
Aileen Gregg

Reputation: 23

How to specify %digit values

I know nothing about bat files and I just received a batch file from a vendor that wants me to replace the values and run the batch.

@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

I know the names, but I do not know how to tell the bat file what they are

Upvotes: 0

Views: 65

Answers (3)

Stephan
Stephan

Reputation: 56180

you are not supposed to replace anything. Those REM lines are just telling you, what parameters are expected.
When the name of the machine and SQL instance is something like Server1-inst05, the name of the database is VendorsBase and the name of the machine 2 is Workstation, you should execute the batchfile (let's call it vendor.bat) like this:

vendor.bat Server1-inst05 VendorsBase Workstation

vendor.bat internally references those three parameters as %1, %2 and %3

(that's the very same information given by npocmaka and BNT; just less technical)

Upvotes: 0

BNT
BNT

Reputation: 984

Update: after the edits and comments i think you are looking for this information.

Its hard to help without the actual code but i assume that what you posted are comments of what the parameter values are.

So you would call the batch file and provide the values as arguments like

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

The script itself would then evaluate the parameters as described e.g. here

Upvotes: 2

npocmaka
npocmaka

Reputation: 57252

%1 %2 %3 are batch file arguments. To set values for them you can create another single line batch file that will call the first want with the arguments you want:

@call database.bat machine database_name machine2

Upvotes: 2

Related Questions