(view source code of secstat.bat as plain text)
@ECHO OFF
:: Check Windows version and WMIC availability
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
VER | FIND "XP" >NUL || GOTO Syntax
SETLOCAL
WMIC.EXE /? >NUL 2>&1 || GOTO Syntax
:: Check command line arguments
IF NOT "%~2"=="" GOTO Syntax
IF "%~1"=="" (SET Computer=%ComputerName%) ELSE (SET Computer=%~1)
ECHO.%* | FINDSTR /R /C:"[/?:;\*]" >NUL && GOTO Syntax
:: Check if specified computer can be reached
IF /I NOT %Computer%==%ComputerName% (
PING %Computer% -n 2 2>NUL | FIND "TTL=" >NUL
IF ERRORLEVEL 1 GOTO Syntax
)
ECHO.
ECHO AntiVirus:
ECHO.==========
FOR /F "tokens=*" %%A IN ('WMIC.EXE /Node:"%Computer%" /Namespace:\\root\SecurityCenter Path AntiVirusProduct Get companyName^,displayName^,onAccessScanningEnabled^,productUptoDate^,versionNumber /Format:List ^| FIND "="') DO SET %%A
IF /I "%productUptoDate%"=="TRUE" (
SET productUptoDate=Yes
) ELSE (
SET productUptoDate=No
)
IF /I "%onAccessScanningEnabled%"=="TRUE" (
SET onAccessScanningEnabled=Enabled
) ELSE (
SET onAccessScanningEnabled=Disabled
)
ECHO Company Name : %companyName%
ECHO Display Name : %displayName%
ECHO On Access Scanning : %onAccessScanningEnabled%
ECHO Product Up-to-date : %productUptoDate%
ECHO Version Number : %versionNumber%
ECHO.
ECHO Firewall:
ECHO.=========
FOR /F "tokens=*" %%A IN ('WMIC.EXE /Node:"%Computer%" /Namespace:\\root\SecurityCenter Path FirewallProduct Get companyName^,displayName^,enabled^,versionNumber /Format:List ^| FIND "="') DO SET %%A
IF /I "%enabled%"=="TRUE" (
SET enabled=Yes
) ELSE (
SET enabled=No
)
ECHO Company Name : %companyName%
ECHO Display Name : %displayName%
ECHO Enabled : %enabled%
ECHO Version Number : %versionNumber%
ECHO.
ECHO Windows Update:
ECHO.===============
FOR /F "tokens=3,4" %%A IN ('REG Query "\\%Computer%\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Download\" /v LastSuccessTime ^| FIND /I "LastSuccessTime"') DO ECHO Last Download : %%A, %%B
FOR /F "tokens=3,4" %%A IN ('REG Query "\\%Computer%\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install\" /v LastSuccessTime ^| FIND /I "LastSuccessTime"') DO ECHO Last Install : %%A, %%B
FOR /F "tokens=3,4" %%A IN ('REG Query "\\%Computer%\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Detect\" /v LastSuccessTime ^| FIND /I "LastSuccessTime"') DO ECHO Last Check : %%A, %%B
FOR /F %%A IN ('WMIC.EXE /Node:%Computer% /Output:STDOUT Path Win32_OperatingSystem Get LastBootUpTime /Format:TABLE') DO SET LastBoot=%%A
SET LastBoot=%LastBoot:~0,14%
ECHO Last Reboot : %LastBoot:~0,4%-%LastBoot:~4,2%-%LastBoot:~6,2%, %LastBoot:~8,2%:%LastBoot:~10,2%:%LastBoot:~12,2%
ENDLOCAL
GOTO:EOF
:Syntax
:: Display help text in StdErr
1>&2 ECHO.
1>&2 ECHO SecStat.bat, Version 2.20 for Windows XP Professional
1>&2 ECHO Display a SecurityCenter status overview for any computer
1>&2 ECHO.
1>&2 ECHO Usage: SECSTAT [ computer ]
1>&2 ECHO.
1>&2 ECHO Where: "computer" is an optional remote computer name
1>&2 ECHO (default is the local computer)
1>&2 ECHO.
1>&2 ECHO Note: Requires WMIC and REG 3, both native in Windows XP Professional.
1>&2 ECHO.
1>&2 ECHO Written by Rob van der Woude
1>&2 ECHO http://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" ENDLOCAL
:: Return code 1
COLOR FF
page last modified: 2024-04-16; loaded in 0.0084 seconds