@echo off :: ##### DETERMINE OS VERSION (32/64bit) #### Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0 REG.exe Query %RegQry% > "%TEMP%\checkOS.txt" Find /i "x86" < "%TEMP%\CheckOS.txt" > "%TEMP%\StringCheck.txt" If %ERRORLEVEL% EQU 0 ( set "INSTALLPATH=%PROGRAMFILES%\FileWave" ) ELSE ( set "INSTALLPATH=%PROGRAMFILES(X86)%\FileWave" ) del /q "%TEMP%\checkOS.txt" "%TEMP%\StringCheck.txt" >NUL 2>&1 :: ##### DETERMINE WINDOWS VERSION #### ver | find /i "version 6.4." > nul if %errorlevel%==0 goto win7 ver | find /i "version 6.3." > nul if %errorlevel%==0 goto win7 ver | find /i "version 6.2." > nul if %errorlevel%==0 goto win7 ver | find /i "version 6.1." > nul if %errorlevel%==0 goto win7 ver | find /i "version 6.0." > nul if %errorlevel%==0 goto win7 ver | find /i "version 5.1." > nul if %errorlevel%==0 goto winxp ver | find /i "version 5.2." > nul if %errorlevel%==0 goto winxp ver | find /i "Windows 2000" > nul if %errorlevel%==0 goto winxp :: if we don't find a match, assume it's a newer version. go to win7 method ( works up until windows 10 currently ) goto win7 goto end :win7 :: check if rules exist netsh advfirewall firewall show rule "FileWave Client" > "%TEMP%\checkfirewall.txt" Find /i "FileWave Client" < "%TEMP%\checkfirewall.txt" > "%TEMP%\StringCheck.txt" If %ERRORLEVEL% EQU 0 ( echo "Rules found - skipping ..." goto end ) ELSE ( echo "No Rules found - creating ..." ) :: set an inbound rule for fwcld.exe netsh advfirewall firewall add rule name="FileWave Client" action=allow program="%INSTALLPATH%\fwcld.exe" enable=yes dir=in description="Filewave Client Inbound Access, usually only port 20010 is needed for client monitor connections" :: set an outbound rule for fwcld.exe netsh advfirewall firewall add rule name="FileWave Client" action=allow program="%INSTALLPATH%\fwcld.exe" enable=yes dir=out description="Filewave Client outbound access, usually only ports 20015-20020 are needed for client monitor connections" if %errorlevel%==0 (echo Ports opened for Windows 7+) else (echo Port Opening Failed) goto end :winxp netsh firewall add allowedprogram program = "%INSTALLPATH%\fwcld.exe" name = "FileWave Client" mode = ENABLE profile = ALL if %errorlevel%==0 (echo Ports opened for Windows XP) else (echo Port Opening Failed) goto end :end del /q "%TEMP%\checkfirewall.txt" "%TEMP%\StringCheck.txt" >NUL 2>&1