2012-06-21 49 views

回答

1

是的,它可以做到。這裏是代碼,引用這個微軟的linkthis之一。將3389替換爲您要使用的新值:

const HKEY_LOCAL_MACHINE = &H80000002 
strComputer = "." 
'Set StdOut = WScript.StdOut 
Set oReg=GetObject(_ 
    "winmgmts:{impersonationLevel=impersonate}!\\" &_ 
    strComputer & "\root\default:StdRegProv") 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" 
strValueName = "PortNumber" 

' Display old value 
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue 
WScript.Echo "Old RDP value=" & dwValue 

' Set new value 
dwValue= 3389 
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue 
If Err = 0 Then 
    oReg.GetDWORDValue _ 
     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue 
    WScript.Echo "New RDP Value =" & dwValue 
Else 
    WScript.Echo "Error in creating key" & _ 
     " and DWORD value = " & Err.Number 
End If 
相關問題