如果你想使用可选参数,而不是命名参数,那么这种方法对我有用。我认为这是更容易遵循的代码。REM Get argument values. If not specified, use default values.IF "%1"=="" ( SET "DatabaseServer=localhost" ) ELSE ( SET "DatabaseServer=%1" )IF "%2"=="" ( SET "DatabaseName=MyDatabase" ) ELSE ( SET "DatabaseName=%2" )REM Do workECHO Database Server = %DatabaseServer%ECHO Database Name = %DatabaseName%