The win server prevents remote UNreachable bat due to security policy or firewall configuration errors

  • 2020-06-12 11:16:25
  • OfStack

Many times we need to login to the server via remote desktop to configure security policy or firewall, which is a very dangerous job. Once a setup is wrong or an operation step is missed, the server cannot connect remotely. If it is a server hosted in the IDC room, you will need to contact the service provider to deal with it, and you will need to give the password to the service provider so that they can access the system to stop the security policy or firewall. In short, the stakes are high!

Really read some of the article, has been put forward such a way of thinking: do a timed task, 10 minutes to trigger 1, the security policy service or firewall service stop. This way, even if you are configured incorrectly and the remote is disconnected, wait outside for at least a few minutes. Wait for time 1, the service is stopped, then go up to operate.

Here, I wrote a batch script. Before configuring the security policy, copy it to the server and save it as a.bat file. And then do it, and then you do it, and of course, you have to control your time.


::-------------------------------------
::  Name: Periodically stop security policy and firewall 
::  Purpose: To prevent remote unconnectivity due to errors while configuring security policies or firewalls 
::  The author: splaybow.com
::  Date: 2013/5/3
::-------------------------------------

@echo off
:: So by default, wait 300 Seconds, you can change it according to the actual situation 
@ping -n 300 127.0.0.1 >nul

@echo  Stopping security Policy service 
@net stop PolicyAgent
@echo  Is to stop Windows Firewall service 
@net stop SharedAccess
@echo.
@echo.
@echo  Processing over! 
@pause

Personally, I think to be a good technology, you must learn to apply non-technical ideas to technical management.


Related articles: