• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

Help with VB Script - Simple Computer Infomation

Hello I am looking to have a script to put on all my user desktops that I can have the user run when I am on the phone with them. I would like the script to show me the following:

PC Name
Logged on user account
Current IP Address
Serial Number

I would like all this info in one window.

I found these scripts which are almost where I can to go but display in different windows:

Thanks for your help!


Dim objWMI:Set objWMI=GetObject("winmgmts:\\.\root\cimv2")
Dim colItems:Set colItems=objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True","WQL")
For each objItem in colItems
  For Each strIP in objItem.IPAddress
    IP=IP & vbNewLine & strIP


Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Next
 
Dim objNet:Set objNet=CreateObject("Wscript.Network")

 
Msgbox "Computer name: " & objNet.Computername & vbCrLf & vbCrLf & "IP Address(es): " & IP & vbNewLine


Set objNet=Nothing
Set colItems=Nothing
Set objWMI=Nothing

Open in new window

strComputer = "." 

Set objWMIService = GetObject("winmgmts:" & _
		"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

For Each objSMBIOS in objWMIService.ExecQuery("Select * from Win32_SystemEnclosure") 
	Wscript.Echo "Serial Number: " & objSMBIOS.SerialNumber 
Next

Open in new window

0
BAYCCS
Asked:
BAYCCS
  • 2
1 Solution
 
cfEngineersCommented:
tested
Dim objWMI:Set objWMI=GetObject("winmgmts:\\.\root\cimv2")
Dim colItems:Set colItems=objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True","WQL")
For each objItem in colItems
  For Each strIP in objItem.IPAddress
    IP=IP & vbNewLine & strIP


Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
		"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
For Each objSMBIOS in objWMIService.ExecQuery("Select * from Win32_SystemEnclosure") 
	myserial = objSMBIOS.SerialNumber
Next
Next
 
Dim objNet:Set objNet=CreateObject("Wscript.Network")

 
Msgbox "Computer name: " & objNet.Computername & vbCrLf & vbCrLf & "IP Address(es): " & IP & vbNewLine & vbNewLine & "Serial Number:" & myserial 


Set objNet=Nothing
Set colItems=Nothing
Set objWMI=Nothing

Open in new window

0
 
cfEngineersCommented:
revamped and added everything you asked for.
wbemImpersonationLevelImpersonate = 3
wbemAuthenticationLevelPktPrivacy = 6
otherinfo = ""
	Set objLocator = CreateObject("WbemScripting.SWbemLocator")
	Set objWMI = objLocator.ConnectServer _
		(strComputer, "root\cimv2", strUser, strPassword)
	objWMI.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
	objWMI.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy

' Get OS name
'
Set colOS = objWMI.InstancesOf ("Win32_OperatingSystem")

For Each objOS in colOS
	strName = objOS.Name
Next

If Instr(strName, "Windows 2000") > 0 Then

	'-------------------------------------------------------------------
	' Code for Windows 2000
	'-------------------------------------------------------------------

	' Get user name
	'
	Set colComputer = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
	
	For Each objComputer in colComputer
		Wscript.Echo "User: " & objComputer.UserName
	Next

	' ------------------------------------------------------------------
	
Else

	' ------------------------------------------------------------------
	' Code for Windows XP or later
	' ------------------------------------------------------------------
	
	' Get interactive session
	'
	Set colSessions = objWMI.ExecQuery _ 
		  ("Select * from Win32_LogonSession Where LogonType = 2") 
	
	If colSessions.Count = 0 Then 
		' No interactive session found
		'
		Wscript.Echo "No interactive user found" 
	Else 
		'Interactive session found
		'
		For Each objSession in colSessions 
		
			Set colList = objWMI.ExecQuery("Associators of " _ 
			& "{Win32_LogonSession.LogonId=" & objSession.LogonId & "} " _ 
			& "Where AssocClass=Win32_LoggedOnUser Role=Dependent" ) 
					
			' Show user info
			'
			For Each objItem in colList 
				otherinfo = "User: " & objItem.Name & vbNewLine _
				& "FullName: " & objItem.FullName & vbNewLine _
				& "Domain: " & objItem.Domain & vbNewLine _
				& "Start Time: " & objSession.StartTime
			Next 
			
			' Show session start time
			'
			'Wscript.Echo "Start Time: " & objSession.StartTime 
		Next 
	End If 
	
	' ------------------------------------------------------------------

End If


Dim objWMI:Set objWMI=GetObject("winmgmts:\\.\root\cimv2")
Dim colItems:Set colItems=objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True","WQL")
For each objItem in colItems
  For Each strIP in objItem.IPAddress
    IP=IP & vbNewLine & strIP


Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
		"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
For Each objSMBIOS in objWMIService.ExecQuery("Select * from Win32_SystemEnclosure") 
	myserial = objSMBIOS.SerialNumber
Next
Next
 
Dim objNet:Set objNet=CreateObject("Wscript.Network")

 
Msgbox "Computer name: " & objNet.Computername & vbCrLf & vbCrLf & "IP Address(es): " & IP & vbNewLine & vbNewLine & "Serial Number:" & myserial & vbNewLine & vbNewLine & otherinfo


Set objNet=Nothing
Set colItems=Nothing
Set objWMI=Nothing

Open in new window

0
 
BAYCCSAuthor Commented:
Excellent Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now