Modify the Registry to enable or disable the Windows Firewall port. Take Remote Desktop port 3389 as an example:
Setport. bat
@ Echo off
Set Ts = "HKLM \ System \ CurrentControlSet \ Control \ Terminal Server"
Set list = "HKLM \ System \ CurrentControlSet \ Services \ sharedaccess \ Parameters
Set list = % List % \ firewallpolicy \ standardprofile \ globallyopenports \ list"
: Open port 3389
If [% 1] = [True] (
Echo % TS %
Echo % List %
Reg add % TS %/V fdenytsconnections/T REG_DWORD/D 0/F
Reg add % List %/V "3389: TCP"/T REG_SZ/D "3389: TCP: *: enabled: @ xpsp2res. dll,-22009"/F
Echo enable remote desktop OK!
Goto end
)
: Disable port 3389.
If [% 1] = [false] (
Echo % TS %
Echo % List %
Reg add % TS %/V fdenytsconnections/T REG_DWORD/D 1/F
Reg add % List %/V "3389: TCP"/T REG_SZ/D "3389: TCP: *: Disabled: @ xpsp2res. dll,-22009"/F
Echo Disable Remote Desktop OK!
Goto end
)
: End
Address: http://www.cnblogs.com/anjou/archive/2007/01/23/628227.html