將下面代碼存為.vbs,雙擊運(yùn)行。然后重啟一下系統(tǒng),就修改了系統(tǒng)的遠(yuǎn)程桌面的默認(rèn)的3389端口
'#####################
'VBS修改遠(yuǎn)程桌面的默認(rèn)端口,并添加至Windows防火墻
'作者51windows.Net
'56868為要設(shè)置的端口
'#####################
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("遠(yuǎn)程桌面56868",56868,1)
set WshShell = nothing
msgbox "設(shè)置成功"
下面是其他人的補(bǔ)充
'**********************************************
'*BY r05e
'*改變終端服務(wù)端口號
'**********************************************
Set WshShell=CreateObject("Wscript.Shell")
Function Imput()
imputport=InputBox("請輸入一個端口號,注意:這個端口號目前不能被其它程序使用,否則會影響終端服務(wù)"," 更改終端端口號", "3389", 100, 100)
If imputport>"" Then
If IsNumeric(imputport) Then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp\PortNumber",imputport,"REG_DWORD"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\PortNumber",imputport,"REG_DWORD"
wscript.echo "操作成功"
Else wscript.echo "輸入出錯,請重新輸入"
Imput()
End If
Else wscript.echo "操作已經(jīng)取消"
End If
End Function
Imput()
set WshShell=nothing
到此這篇關(guān)于用VBS修改遠(yuǎn)程桌面3389端口并添加到Windows防火墻的代碼的文章就介紹到這了,更多相關(guān)VBS修改遠(yuǎn)程桌面的默認(rèn)端口內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- Linux下查看端口占用進(jìn)程號,程序名的方法
- Linux SSH 安全策略 更改 SSH 端口
- Linux VPS安全設(shè)置之一 修改SSH端口(CentOS/Debian)
- Windows批量添加防火墻例外端口的批處理代碼
- Linux/window下怎樣查看某個端口被哪個程序/進(jìn)程占用
- linux 監(jiān)視端口是否正常的shell腳本
- windows apache多端口虛擬主機(jī)配置方法
- linux環(huán)境apache多端口配置虛擬主機(jī)的方法深入介紹
- C#獲取Windows進(jìn)程監(jiān)聽的TCP/UDP端口實例
- Windows服務(wù)器系統(tǒng)服務(wù)端口對照表
- Windwos下使用winscp和批處理實現(xiàn)通過SSH端口上傳文件到Linux服務(wù)器上
- 如何解決windows系統(tǒng)和linux系統(tǒng)中端口被占用的問題