lwg said:
In our logon script I would like to check for the presense of two servers
as an expample. i.e. if %computername%=server1 or server2... How should this
line be formatted? Thank you for your help...
Unfortunately batch files don't have an OR statement, so it's not simple.
You could do something like this:
SetLocal
Set RESULT=1
If /I "%COMPUTERNAME%" EQU "server1" Set RESULT=0
If /I "%COMPUTERNAME%" EQU "server2" Set RESULT=0
If %RESULT% EQU 0 (
REM This is server1 or server2
) Else (
REM This is not server1 or server2
)
Or you could use FINDSTR.EXE with the ^ and $ regular expressions:
(the first line is long, it might get line-wrapped)
Echo %COMPUTERNAME%|FindStr.exe /r /i "^server1$ ^server2$">NUL
If %ERRORLEVEL% EQU 0 (
REM This is server1 or server2
) Else (
REM This is not server1 or server2
)