"Jake" <jake_...@hotmail.com> wrote in message
news:101cf01c27f51$ff237eb0$37ef2ecf@TKMSFTNGXA13...
>.
>
Remote Desktop
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Termina
l Server\fDenyTSConnections
Use REG_DWORD with a value of 0 or 1
0 turns on 1 turns off
>.
>
>.
>
---------------------------------------------
Function blnConnect(objService, strServer, strNameSpace, strUserName,
strPassword)
ON ERROR RESUME NEXT
DebugPrint "blnConnect: started"
Dim objLocator
blnConnect = True 'There is no error.
' Create Locator object to connect to remote CIM object manager
Err.Clear
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
If Err.Number then
WSCript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in
creating a locator object."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
WScript.Echo "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = False 'An error occurred
Exit Function
End If
Err.Clear
' Connect to the namespace which is either local or remote
Set objService = objLocator.ConnectServer (strServer, strNameSpace,
strUserName, strPassword)
If Err.Number then
WScript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in
connecting to server " _
& strServer & "."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
WScript.Echo "Error description: " & Err.Description & "."
End If
Err.Clear
blnConnect = False 'An error occurred
End If
objService.Security_.impersonationlevel = 3
if blnConnect = True then
DebugPrint "blnConnect: succeeded"
end if
End Function
'********************************************************************
Dim objServices
WScript.Echo "Start"
blnResult = blnConnect( objServices, "MyRemoteMachine", "root\cimv2",
"MyRemoteMachine\Administrator", "MyPassword" )
if not blnResult then
WScript.Echo "Error connecting"
MsgBox "Error connecting", vbExclamation, "Error"
End If
set terminal = objServices.Get("win32_TerminalServiceSetting='RDP-Tcp'")
result = terminal.SetAllowTSConnections( "1" )
WScript.Echo "Method returned result = " & result
if err <>0 then
WScript.Echo Err.Description, "0x" & Hex(Err.Number)
end if
-------------------------------------------------
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jake" <jake_...@hotmail.com> wrote in message
news:12ed01c2802b$64cf6e20$36ef2ecf@tkmsftngxa12...