Modify Remote Desktop 3389 port with VBS and add code to Windows Firewall _vbs

Source: Internet
Author: User
Save the following code as a. vbs, and double-click to run. Then reboot the system and modify the default 3389 port on the system's Remote Desktop

'#####################
' VBS modifies the default port for Remote Desktop and adds it to Windows Firewall
' Author 51windows.net
' 56868 is the port you want to set
'#####################

Set WshShell = WScript.CreateObject ("Wscript.Shell")
WshShell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\ PortNumber ", 56868," REG_DWORD "
WshShell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp\ PortNumber ", 56868," REG_DWORD "


Function Addfirewall (name,port,state)
Set Objfirewall = CreateObject ("Hnetcfg.fwmgr")
Set Objpolicy = ObjFirewall.LocalPolicy.CurrentProfile

Set Objport = CreateObject ("Hnetcfg.fwopenport")
Objport.port = Port
Objport.name = Name
objport.enabled = State
Set colports = Objpolicy.globallyopenports
Errreturn = Colports.add (objport)
End Function

Call Addfirewall ("Remote Desktop 56868", 56868, 1)
Set WshShell = Nothing

MsgBox "Set Success"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.