IP安全策略
@echo off
:again
set num=
set ippolicyname=
set ismmpfs=
set keytime=
set keyexpress=
set newippolicyname=
set policylocation=
setlocal EnableDelayedExpansion
cls
echo.
echo.
echo --------------------请选择要执行的操作--------------------
echo -----.创建一个IP安全策略
echo -----.创建自定义密钥交换安全措施的IP策略
echo -----.删除指定的安全策略
echo -----.修改指定IP安全策略的配置信息
echo -----.设置IP安全策略的存储位置
echo -----.退出程序
echo.
echo.
set /p num=请选择要执行的操作:
if "!num!"=="" (
set /p ippolicyname=请输入IP安全策略的名称:
set /p comment=请输入IP安全策略的描述信息:
set /p ismmpfs=若启用主密钥完全向前保密请输入yes,否则输入no:
set /p keytime=请输入密钥生成时间:
echo.
netsh ipsec static add policy name=!ippolicyname! description=!comment! mmpfs=!ismmpfs! mmlifetime=!keytime!
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p ippolicyname=请输入IP安全策略的名称:
set /p comment=请输入IP安全策略的描述信息:
set /p ismmpfs=若启用主密钥完全向前保密请输入yes,否则输入no:
set /p keytime=请输入密钥生成时间:
set /p keyexpress=请输入密钥交换措施表达式:
echo.
netsh ipsec static add policy name=!ippolicyname! description=!comment! mmpfs=!ismmpfs! mmlifetime=!keytime! mmsecmethods=^
"!keyexpress!"
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p ippolicyname=请输入要删除的IP安全策略名称:
echo.
netsh ipsec static delete policy name=!ippolicyname!
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p ippolicyname=请输入IP安全策略的名称:
set /p newippolicyname=请输入IP安全策略的新名称:
set /p comment=请输入IP安全策略的描述信息:
set /p ismmpfs=若启用主密钥完全向前保密请输入yes,否则输入no:
set /p keytime=请输入密钥生成时间:
set /p keyexpress=请输入密钥交换措施表达式:
echo.
netsh ipsec static set policy name=!ippolicyname! newname=!newippolicyname! description=!comment! mmpfs=!ismmpfs!^ mmlifetime=!keytime! mmsecmethods="!keyexpress!"
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p policylocation=请输入IP安全策略的存储位置:
echo.
netsh ipsec static set store location=!policylocation!
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
goto end
)
if "!num!"=="" (
goto again
)
if not "!num!"=="" (
echo 选择错误,请按任意键返回主菜单后重新选择!
pause > nul
goto again
)
:end
exit