HAKSA
asked on
VB Script to check on Remote Desktop
Greetings,
I have a list of IP addresses and i would like to check if any of those IPs have the remote desktop service enabled. Currently i'm doing the check manually by inserting one by one into the remote desktop connection windows. could anyone help me to Script this process.
Thanks
I have a list of IP addresses and i would like to check if any of those IPs have the remote desktop service enabled. Currently i'm doing the check manually by inserting one by one into the remote desktop connection windows. could anyone help me to Script this process.
Thanks
telnet servername 3389 You should get a black screen.You can test that for each and every server.
ASKER
Thanks mboppe for the advice. How can i incorporate your idea into a VBS where i provide a list of IP addresses and i get back a list of the IPs along with thier RDC status weather enable or not.
I don't know if its can be scripted.This what i tried but just stops at the 1st server.Servers.txt should have a list of serversnames
for /f %%a in (c:\servers.txt) do (
telnet %%a 3389
)
for /f %%a in (c:\servers.txt) do (
telnet %%a 3389
)
Do you have admin privileges on all the hosts? If so, read on...
You could use a script to check Win32_TerminalServiceSetti ng. This method doesn't seem to work too well on Win7/Vista though.
Another method is to check the registry on the hosts. Here's a script that I made for checking the registry on hosts specified in C:\servers.txt. Tested on Win2K,XP,Vista and Win7.
You could use a script to check Win32_TerminalServiceSetti
Another method is to check the registry on the hosts. Here's a script that I made for checking the registry on hosts specified in C:\servers.txt. Tested on Win2K,XP,Vista and Win7.
ON ERROR RESUME NEXT
'Force CSCRIPT
Set WshShell=CreateObject("Wscript.Shell")
If instr(lcase(wscript.fullname),"wscript") then
wshshell.run "cmd /k cscript //nologo " & chr(34) & wscript.scriptfullname & Chr(34),1,false
wscript.quit
End If
Const HKEY_LOCAL_MACHINE = &H80000002
strFilename="c:\servers.txt"
Set fso=CreateObject("Scripting.FileSystemObject")
'Verify server list file exists
If NOT fso.FileExists(strFilename) then
msgbox "Could not find file: " & strFilename,vbExclamation,"Remote Desktop Check"
wscript.quit
End If
'Read the server file
Set oFile=fso.OpenTextFile(strFilename,1)
text = oFile.ReadAll
oFile.Close
arrComputers = split(text,vbCrLf)
For Each strComputer in arrComputers
status=""
status=GetVal(strComputer,"fDenyTSConnections")
If status="UNKNOWN" then
status=GetVal(strComputer,"TSEnabled")
End If
wscript.echo strComputer & "=" & status
Next
Function GetVal(strComputer,strValueName)
ON ERROR RESUME NEXT
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
If err.number <> 0 then
strValue=err.number
err.clear
Else
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If err.number <> 0 then
strValue=err.number
err.clear
End If
End If
IF strValueName="fDenyTSConnections" then
If strValue="0" then
strValue="1"
ElseIf strValue="1" then
strValue="0"
End If
End If
Select Case strValue
Case "1"
GetVal="Enabled"
Case "0"
GetVal="Disabled"
Case "462"
GetVal="UNAVAILABLE"
Case "-2147217405"
GetVal="ACCESS DENIED"
Case Else
GetVal="UNKNOWN"
End Select
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is what i was looking for. Thanks
There is a similar kind of post in EE. Try this
https://www.experts-exchange.com/questions/22701120/Check-for-remote-desktop-connection-in-VBscript.html