Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. Author Comment
  2. NuttyBar2013-08-17 at 07:46:08ID: 39416830
  3.  
  4. I found this script that works on some systems, but others it gives me a RPC Server is unavailable, even though the RPC Server is running
  5.  
  6.  
  7.  
  8. Set objFSO = CreateObject("Scripting.FileSystemObject")
  9. Set objIn = objFSO.OpenTextFile(".\machinelist.txt",1)
  10. Set objOut = objFSO.OpenTextFile(".\Output.txt",2,True)
  11.  
  12. struser = "xxx\xxx"
  13. strPassword = "xxx"
  14.  
  15. strNamespace = "root\cimv2"
  16.  
  17. Do Until objIn.AtEndOfStream
  18. strComputer = objIn.readline
  19. If Ping(strComputer) = True Then
  20. Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
  21. Set objWMIService = objwbemLocator.ConnectServer _
  22. ( strComputer, strNamespace, struser, strPassword)
  23. 'objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
  24. Set colComputer = objWMIService.ExecQuery("Select UserName from Win32_ComputerSystem")
  25. For Each objComputer In colComputer
  26. strUserName = "User Name: " & objComputer.UserName
  27. Next
  28. If strUserName = "" Then
  29. objOut.WriteLine strComputer & vbTab & "Last user Not found"
  30. Else
  31. objOut.writeline strComputer & vbTab & strUserName
  32. End If
  33. Else
  34. objOut.writeline strComputer & vbTab & "no Contact"
  35. End If
  36. Loop
  37. objout.close
  38. Function Ping(strComputer)
  39. Dim objShell, boolCode
  40. Set objShell = CreateObject("WScript.Shell")
  41. boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
  42. If boolCode = 0 Then
  43. Ping = True
  44. Else
  45. Ping = False
  46. End If
  47. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement