我正在尝试创建一个批处理文件,该文件调用其他批处理文件,这些文件在启动时解锁服务器上的特定驱动器。我知道解锁脚本有效。如果我运行它们,驱动器就会解锁。但是,当我尝试通过创建另一个批处理脚本来根据服务器名称调用这些脚本来自动化它时,它无法解锁。手动运行脚本时,它告诉我调用的脚本具有不正确的解锁代码。
我尝试添加目标服务器的全名。
代替
If %computername% == "PartialServername*" Goto Servername
我把它改成
If %computername% == "Servername" Goto Servername
我也尝试将其运行为:
If %computername% == "Servername" Call Servername.bat
这有效,但如果我有多行if
.
服务器解锁.bat
pushd "\\servername\scripts\unlock scripts\"
If %computerName% == "PartialServerName1*" Goto Servername
:Servername Call Servername.Bat
服务器名.bat
manage-bde -unlock d: -recoverypassword *Recovery key here*
我希望它会调用批处理文件并解锁驱动器,但批处理文件会调用该文件,然后说恢复密码错误。
完整脚本:
REM Created temporary network drive to the unlock scripts folder on vipre
pushd "\\scriptserver\unlock scripts\"
REM Checks the value of the Server name then goes to that section of the
script REM to run the appropriate script
If %computerName% == "Bow*" Goto Bow
If %computerName% == "Del*" Goto Del
If %computerName% == "Fin*" Goto Fin
If %computerName% == "Gah*" Goto Gah
If %computerName% == "Gib*" Goto Gib
If %computerName% == "Kal*" Goto Kal
If %computerName% == "Ken*" Goto Ken
If %computerName% == "Lei*" Goto Lei
If %computerName% == "Lew*" Goto Lew
If %computerName% == "Lim*" Goto Lim
If %computerName% == "Loa*" Goto Loa
If %computerName% == "Mar*" Goto Mar
If %computerName% == "Ott*" Goto Ott
If %Computername% == "Pem*" Goto Pem
If %computerName% == "Ric*" Goto Ric
If %computerName% == "Sha*" Goto Sha
If %computerName% == "Wes*" Goto Wes
:Bow
Call Bow.bat
Call DistributionRestart.bat
popd
:Del
Call Del.bat
Call DistributionRestart.bat
popd
:Fin
Call Fin.bat
Call DistributionRestart.bat
popd
:Gah
Call Gah.bat
Call DistributionRestart.bat
popd
:Gib
Call Gib.bat
Call DistributionRestart.bat
popd
:Kal
Call Kal.bat
Call DistributionRestart.bat
popd
:Ken
Call Ken.bat
Call DistributionRestart.bat
popd
:Lei
Call Lei.bat
Call DistributionRestart.bat
popd
:Lew
Call Lew.bat
Call DistributionRestart.bat
popd
:Lim
Call Lim.bat
Call DistributionRestart.bat
popd
:Loa
Call Loa.bat
Call DistributionRestart.bat
popd
:Mar
Call Mar.bat
Call DistributionRestart.bat
popd
:Ott
Call Ott.bat
Call DistributionRestart.bat
popd
:Pem
Call Pem.bat
Call DistributionRestart.bat
popd
:Ric
Call Ric.bat
Call DistributionRestart.bat
popd
:Sha
Call Sha.bat
Call DistributionRestart.bat
popd
:Wes
Call Wes.bat
popd