用VBS修改远程桌面3389端口并添加到Windows防火墙的代码
程序员文章站
2022-04-10 08:12:57
将下面代码存为.vbs,双击运行。然后重启一下系统,就修改了系统的远程桌面的默认的3389端口 '##################### 'vbs修改远程桌面的默认端口...
将下面代码存为.vbs,双击运行。然后重启一下系统,就修改了系统的远程桌面的默认的3389端口
'#####################
'vbs修改远程桌面的默认端口,并添加至windows防火墙
'作者51windows.net
'56868为要设置的端口
'#####################
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("远程桌面56868",56868,1)
set wshshell = nothing
msgbox "设置成功"
'#####################
'vbs修改远程桌面的默认端口,并添加至windows防火墙
'作者51windows.net
'56868为要设置的端口
'#####################
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("远程桌面56868",56868,1)
set wshshell = nothing
msgbox "设置成功"