| Junior Member with 1 posts. | | |
08-Mar-2005, 08:55 AM
#11 |
Option Explicit
const COMMAND_EXEC = "NETSH WINS SERVER \\10.0.3.18 show name "
const COMMAND_VNC = "C:\Program Files\RealVNC\vncviewer.exe "
'const COMMAND_VNC = "C:\Program Files\ORL\VNC\vncviewer.exe "
Dim objWshShell , objExec, strUserName, strOutput, intLine, oshell
Dim intPosition, strIP, arrEntrySplit, strComputerName, intRemote
strUserName = InputBox("Please enter a user name:" & vbCRLF & vbCRLF & _
"(Press [ENTER] or click [CANCEL] to exit...)", _
"spoogenet.com", "")
Do While strUserName <> ""
Set objWshShell = CreateObject("WScript.Shell")
Set objExec = objWshShell.Exec (COMMAND_EXEC & strUserName & " 03")
For intLine = 1 To 4
objExec.StdOut.ReadLine
Next
If objExec.StdOut.ReadLine <> "The name does not exist in the WINS database." Then
For intLine = 1 To 5
objExec.StdOut.ReadLine
Next
strOutput = objExec.StdOut.ReadLine
If Left(strOutput,10) <> "IP Address" Then
strOutput = objExec.StdOut.ReadLine
End If
intPosition = InStr(strOutput, ":")
strIP = Right(strOutput, (Len(strOutput) - intPosition))
Set objExec = objWshShell.Exec("NBTSTAT -A " & strIP)
Do While Not objExec.StdOut.AtEndOfStream
strOutput = objExec.StdOut.ReadLine
If InStr(strOutput,"<03>") <> 0 Then
arrEntrySplit = Split(strOutput)
If UCase(arrEntrySplit(4)) <> UCase(strUserName) And _
UCase(arrEntrySplit(4)) <> UCase(strComputerName) And _
UCase(arrEntrySplit(4)) <> strComputerName & "$" Then
strComputerName = strComputerName & UCase(arrEntrySplit(4))
End If
End If
Loop
If strComputerName <> "" Then
MsgBox "The requested user '" & strUserName & _
"' is logged on to: " & strComputerName,,"User Computer Name Locator"
Else
MsgBox "The requested user '" & strUserName & _
"' doesn't appear to logged on to the network. "
End If
Else
MsgBox "The user was not found in the WINS database. ",, _
"User Computer Name Locator"
End If
Set objExec = Nothing
Set objExec = objWshShell.Exec (COMMAND_VNC & strComputerName)
WScript.Sleep 1000
objwshshell.Sendkeys("password")
WScript.Sleep 1000
objwshshell.SendKeys("{ENTER}")
WScript.Sleep 1000
'Send ctrl + alt + del to vncviewer
'objwshshell.Sendkeys("%^+{DEL}")
Set objExec = Nothing
strComputerName = ""
strUserName = InputBox("Please enter a user name:" & vbCRLF & vbCRLF & _
"(Press [ENTER] or click [CANCEL] to exit...)", _
"User Computer Name Locator", "")
Loop |