Login | |
|
 |
display computer name of client pc - 7/9/2004 2:15:37 AM
|
|
 |
|
| |
bpsi489
Posts: 1
Score: 0
Joined: 7/9/2004
From: Philippines
Status: offline
|
Hi All, Could anyone please help me how to add the computer name in this script to be displayed? Thanks. '~~Comment~~. 'This program displays the full name of a given username. '~~Script~~. Option Explicit ' Declare variables. Dim Domainname, Username Dim WshNetwork Dim SearchPos Dim User Dim ErrNum ' Parse parameters provided by user. ' If no parameters are provided, prompt user for username. ' If parameter is '/?', display help. ' If more than one parameter is specified, display errormessage. Select Case Wscript.Arguments.Count Case 0 Set WshNetwork = Wscript.CreateObject("Wscript.Network") Username = InputBox("This program displays the full name of a given username." & vbCrLf & vbCrLf & "Please enter an username in the field below." & vbCrLf & vbCrLf & "Syntax: [Domainname\]Username", "Fullname.vbs", WshNetwork.UserDomain & "\" & WshNetwork.UserName) If Username = "" Then Wscript.Quit(0) Case 1 Username = Wscript.Arguments(0) If Username = "/?" Then MsgBox "This program displays the full name of a given username." & vbCrLf & vbCrLf & "Usage: Fullname.vbs [[domainname\]username]" & vbCrLf & vbCrLf & "If no parameters are provided, Fullname.vbs will prompt for a username." & vbCrLf & "If no domainname is provided, Fullname.vbs will use the current domain.", vbOKOnly + vbInformation, "Fullname.vbs" Wscript.Quit(0) End If Case Else MsgBox "ERROR: Too much parameters." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(1) End Select ' Get Domainname and Username. ' If domainname is not specified, get the current domainname. ' If domainname or username are blank, display errormessage. SearchPos = InStr(Username, "\") If SearchPos = 0 Then Set WshNetwork = Wscript.CreateObject("Wscript.Network") Domainname = WshNetwork.UserDomain Else Domainname = Left(Username, SearchPos - 1) Username = Mid(Username, SearchPos + 1) End If If Domainname = "" Then MsgBox "ERROR: Domainname is empty." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(2) ElseIf Username = "" Then MsgBox "ERROR: Username is empty." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(3) End If ' Check Username for errors. ' If username still contains '\', display errormessage. ' If username contains '/', display errormessage. SearchPos = InStr(Username, "\") If SearchPos <> 0 Then MsgBox "ERROR: Username contains too much '\' characters." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(4) End If SearchPos = InStr(Username, "/") If SearchPos <> 0 Then MsgBox "ERROR: Username contains '/' character." & vbCrLf & vbCrLf & "Use '\' between domainname and username." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(5) End If ' Get Fullname. ' If binding to user fails, display errormessage. On Error Resume Next 'we need to disable WSH error checking to verify if binding to user was succussfull or not. Set User = GetObject("WinNT://" & Domainname & "/" & Username & ",User") ErrNum = Err.Number On Error GoTo 0 're-enable WSH error checking. If ErrNum = 0 Then MsgBox "Domainname : " & Domainname & vbCrLf & "Username : " & Username & vbCrLf & vbCrLf & "Fullname : " & User.Fullname, vbOKOnly + vbInformation, "Fullname.vbs" Else MsgBox "ERROR: Failed to bind to " & "WinNT://" & Domainname & "/" & Username & ",User" & vbCrLf & vbCrLf & "Check domainname and username." & vbCrLf & vbCrLf & "Use 'Fullname.vbs /?' for more help.", vbOKOnly + vbCritical, "Fullname.vbs" Wscript.Quit(6) End If ' End of script. WScript.Quit(0)
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|