Question

I am not an advanced scriptor but know of the many possibilities. I have a custom batch file, with menu, for performing several tasks from one window (Such as install from domain, enable/disable firewall, etc) but, I need to pipe the status of Windows 7 machine firewalls to the title bar in a similar format as below:

{---------------} Tech Tools --- FW:000 {---------------}

The title is 'Tech Tools.' Next to it, it would show the firewall status for all profiles in the form of zeros or ones; zero for disabled, ones for enabled.

So far I have found this to give me the most basic information I could find:

   NETSH ADVFIREWALL SHOW ALLPROFILE STATE

I have been brainstorming on maybe using IF statements and variablees to set relationships between the STATE info and 1/0 and piping it to TITLE.

Thanks in advanced.

Was it helpful?

Solution

I'm totally not sure if I understand the question , but...

@echo off

setlocal enableDelayedExpansion
set "states="
for /f "eol=- tokens=2" %%a in ('NETSH ADVFIREWALL SHOW ALLPROFILES STATE^|find /i "state"') do (
    if /i "%%a" EQU "ON" (
        set states=!states!1 
    ) else (
        set states=!states!0
    )
)

title {---------------} Tech Tools --- FW:!states! {---------------}

endlocal
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top