![尝试在 IF 语句中使用通配符](https://linux22.com/image/1575672/%E5%B0%9D%E8%AF%95%E5%9C%A8%20IF%20%E8%AF%AD%E5%8F%A5%E4%B8%AD%E4%BD%BF%E7%94%A8%E9%80%9A%E9%85%8D%E7%AC%A6.png)
我正在尝试根据机器主机名执行一些命令,但无法正常工作。我希望只有当主机名以“Machine”开头时,命令才会运行。IF 语句是否支持通配符?
@echo off
setlocal enableDelayedExpansion
for /f "usebackq skip=1" %%i in (`wmic computersystem get name`) do (
set name=%%i
goto :done
)
:done
if [%name%]==[MachineXXXX] start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "download url"
endlocal