Results 1 to 5 of 5

Thread: VBscript help

  1. #1
    FLAC
    Join Date
    Apr 2005
    Location
    Queens, New York
    Posts
    1,386

    VBscript help

    Ok so the company I work for has 6000+ PC's. I came across a VB script where you enter a username and it returns the computer name that person is on. Here is the code: (from http://windowsitpro.com/windowsscrip...ged-on-to.html)

    Code:
    Option Explicit
    
    Dim objShell, objExec, strUserName, strOutput, intLine
    Dim intPosition, strIP, arrEntrySplit, strComputerName, intRemote
    
    Set objShell = CreateObject("WScript.Shell")
    strUserName = InputBox("Please enter a user name:" & vbCRLF & vbCRLF & _
       "(Press [ENTER] or click [CANCEL] to exit...)", _
       "User Computer Name Locator", "")
    
    Do While strUserName <> ""
       Set objExec = objShell.Exec("NETSH WINS SERVER \\WinsServerName SHOW NAME " _
          & 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) - 0)
          Set objExec = objShell.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
       strComputerName = ""
       strUserName = InputBox("Please enter a user name:" & vbCRLF & vbCRLF & _
          "(Press [ENTER] or click [CANCEL] to exit...)", _
          "User Computer Name Locator", "")
    Loop
    Here is the thing, the script works really well but unfortunately, it only works with Windows 2000 based PC's. It does not work for Windows XP based PC's. Could somebody help me fix it up where it would work on both 2000 and XP systems?
    2002 Mitsubishi Galant
    Progress: 90% [-▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓- ->

    Carputer Specs:
    Via M10K
    512mb Ram
    60GB HDD
    Souund Blaster Audigy2 NX
    OPUS ITX PC Case


  2. #2
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,435
    I think that's because NBTSTAT -A's output on XP machines is different to 2000 machines.

    The significant difference I can see is that is does not provide the username.


    One way would be to set up a logon script that updates a database as user logs in as to which PC they are on. And another to run when they logout that removes them fro that PC. (one issue with this would be if they PC crashes they wouldn't be updated)


    Or have a program that runs in the background that updates that info periodically.


    However isn't there some kind of server tool that allows this info to be found.

  3. #3
    FLAC
    Join Date
    Apr 2005
    Location
    Queens, New York
    Posts
    1,386
    What I don't understand is if works for win2000 y not xp? Their has got to be a way where the script will work. I was reading something about the objWMIService.

    The company I work for probably won't let us install ne software for this. So the script is the best and easiest way
    2002 Mitsubishi Galant
    Progress: 90% [-▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓- ->

    Carputer Specs:
    Via M10K
    512mb Ram
    60GB HDD
    Souund Blaster Audigy2 NX
    OPUS ITX PC Case


  4. #4

  5. #5
    Constant Bitrate almera's Avatar
    Join Date
    Aug 2004
    Posts
    195
    ----------------------------------------------------------------------

Similar Threads

  1. How to create a C++ COM object for StreetDeck
    By god_of_cpu in forum DigitalMods (Scripts / API)
    Replies: 20
    Last Post: 04-06-2008, 05:48 PM
  2. SD vbscript
    By 06TC_OWNER in forum DigitalMods (Scripts / API)
    Replies: 2
    Last Post: 07-18-2007, 02:27 PM
  3. RoadRunner... Would It Ever
    By Jaz in forum Road Runner
    Replies: 19
    Last Post: 12-11-2006, 12:03 AM
  4. Running a VBScript from a button
    By JohnWPB in forum Road Runner
    Replies: 5
    Last Post: 10-27-2006, 10:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •