批处理设置防火墙、系统休眠&睡眠、用户控制设置

一、设置防火墙

  • 新方法:关闭&开启 专用网络防火墙、来宾或公用网络防火墙、域防火墙
netsh advfirewall set allprofiles state on    -开启所有网络防火墙
netsh advfirewall set allprofiles state off   -关闭所有网络防火墙

netsh advfirewall set privateprofile state on   -开启专用网络防火墙
netsh advfirewall set privateprofile state off  -关闭专用网络防火墙
netsh advfirewall set publicprofile state on    -开启来宾或公用网络防火墙
netsh advfirewall set publicprofile state off   -关闭来宾或公用网络防火墙
netsh advfirewall set domainprofile state on    -开启域防火墙
netsh advfirewall set domainprofile state off   -关闭域防火墙
  • 旧方法:关闭&开启 关闭专用网络、来宾或公用网络防火墙(已弃用)
netsh firewall set opmode mode=disable profile=ALL  -关闭专用网络
netsh firewall set opmode mode=enable profile=ALL   -开启专用网络
netsh firewall set opmode mode=disable              -关闭来宾或公用网络防火墙
netsh firewall set opmode mode=enable               -开启来宾或公用网络防火墙

二、设置系统休眠时间、睡眠时间和关闭显示器时间

  • 设置计算机睡眠时间:从不
powercfg -change -standby-timeout-ac 0
  • 设置计算机睡眠时间:15分钟
powercfg -change -standby-timeout-ac 15
  • 设置计算机休眠时间:从不
powercfg -change hibernate-timeout-ac 0
  • 设置计算机休眠时间:15分钟
powercfg -change hibernate-timeout-ac 15
  • 设置关闭显示器:从不
powercfg -change -monitor-timeout-ac 0
--
其他方法:powercfg -x -monitor-timeout-ac 0
  • 设置关闭显示器:15分钟
powercfg -change -monitor-timeout-ac 15

三、更改用户账号控制设置(修改注册表)

  • 从不通知
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /t "REG_DWORD" /d 0 /F
  • 始终通知
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /t "REG_DWORD" /d 2 /F

四、封装bat脚本

@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

call:Close_Firewall
call:Turn_Off_Device_Hibernation
call:Change_User_Permissions
pause
exit

REM 关闭专用、来宾或公用网络防火墙
:Close_Firewall
netsh advfirewall set privateprofile state off >nul
netsh advfirewall set publicprofile state off >nul
echo The firewall is turned off
goto:eof

REM 计算机睡眠状态、休眠状态和关闭显示器设置为:从不
:Turn_Off_Device_Hibernation
powercfg -change -standby-timeout-ac 0
powercfg -change hibernate-timeout-ac 0
powercfg -change -monitor-timeout-ac 0
echo The computer sleep time and turning off the monitor have been set to never
goto:eof

REM 更改用户帐户控制设置为:从不通知
:Change_User_Permissions
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /t "REG_DWORD" /d 0 /F >nul
echo The user account control setting has been changed to: Never notify
goto:eof
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值