Sponsored links

Go Back   MP3Car.com > General > Off Topic


Reply
 
Share Thread Tools Display Modes
Old 05-16-2008, 09:29 PM   #1
FLAC
 
Join Date: Apr 2005
Location: Queens, New York
Posts: 1,385
Cheekz185 will become famous soon enough
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

Cheekz185 is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 05-17-2008, 08:21 AM   #2
Confusion Master
 
Enforcer's Avatar
 
Join Date: Sep 2003
Location: If you go down to the woods today, You're sure of
Posts: 11,928
Enforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant future
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.

Last edited by Enforcer; 05-17-2008 at 08:28 AM.
Enforcer is offline   Reply With Quote
Old 05-17-2008, 12:14 PM   #3
FLAC
 
Join Date: Apr 2005
Location: Queens, New York
Posts: 1,385
Cheekz185 will become famous soon enough
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

Cheekz185 is offline   Reply With Quote
Old 05-17-2008, 12:31 PM   #4
Confusion Master
 
Enforcer's Avatar
 
Join Date: Sep 2003
Location: If you go down to the woods today, You're sure of
Posts: 11,928
Enforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant futureEnforcer has a brilliant future
Like I said, NBTSTAT does NOT appear to give the username in XP but it does for Win2K.
Enforcer is offline   Reply With Quote
Old 05-17-2008, 01:41 PM   #5
Constant Bitrate
 
almera's Avatar
 
Join Date: Aug 2004
Posts: 176
almera is on a distinguished road
http://www.pcreview.co.uk/forums/thread-634456.php
__________________
----------------------------------------------------------------------
almera is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a C++ COM object for StreetDeck god_of_cpu DigitalMods (Scripts / API) 20 04-06-2008 06:48 PM
SD vbscript 06TC_OWNER DigitalMods (Scripts / API) 2 07-18-2007 03:27 PM
RoadRunner... Would It Ever Jaz Road Runner 19 12-11-2006 01:03 AM
Running a VBScript from a button JohnWPB Road Runner 5 10-27-2006 11:31 PM



All times are GMT -5. The time now is 03:30 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics