I need a little bit of help there. I will like to call the attached batch file in a VBScript where I will prompt for an IP address and pass on the IP (%1) to the batch file
@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
set IP=%1
REM Get Serial
call :DoSnmpGet "%IP%" ".1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0" "Serial"
REM If no serial found, try the XEROX MIB to see if it responds
if "!Serial!"=="N/A" (
call :DoSnmpGet "%IP%" ".1.3.6.1.2.1.43.5.1.1.17.1" "Serial"
REM If no serial found, try the RICOH MIB to see if it responds
if "!Serial!"=="N/A" (
call :DoSnmpGet "%IP%" ".1.3.6.1.4.1.367.3.2.1.2.1.4.0" "Serial"
if NOT "!Serial!"=="N/A" (
for /F "tokens=1 delims=," %%z in (!Serial!) do set Serial=%%z
set Serial=!Serial:"=!
)
) else (
for /F "tokens=1 delims=," %%z in (!Serial!) do set Serial=%%z
set Serial=!Serial:"=!
)
)
echo Serial=%Serial%
pause
exit /b
:DoSnmpGet
REM Use SNMPGET to fetch value for IP and MIB passed in, return in variable passed in
set %~3=N/A
for /F "tokens=1-3*" %%t in ('snmpget -O T -v 1 -c public %~1 %~2 2^>nul^|find "="') do (
set SnmpgetResult=%%w
if "%%v"=="Hex-STRING:" (
set SnmpgetResult=!SnmpgetResult: =!
for /F "tokens=2 delims=[.]" %%z in ("!SnmpgetResult!") do set SnmpgetResult=%%z
)
set %~3=!SnmpgetResult!
)
exit /b
Cheers