Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Author Comment
- NuttyBar2013-08-17 at 07:46:08ID: 39416830
- 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
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objIn = objFSO.OpenTextFile(".\machinelist.txt",1)
- Set objOut = objFSO.OpenTextFile(".\Output.txt",2,True)
- struser = "xxx\xxx"
- strPassword = "xxx"
- strNamespace = "root\cimv2"
- Do Until objIn.AtEndOfStream
- strComputer = objIn.readline
- If Ping(strComputer) = True Then
- Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
- Set objWMIService = objwbemLocator.ConnectServer _
- ( strComputer, strNamespace, struser, strPassword)
- 'objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
- Set colComputer = objWMIService.ExecQuery("Select UserName from Win32_ComputerSystem")
- For Each objComputer In colComputer
- strUserName = "User Name: " & objComputer.UserName
- Next
- If strUserName = "" Then
- objOut.WriteLine strComputer & vbTab & "Last user Not found"
- Else
- objOut.writeline strComputer & vbTab & strUserName
- End If
- Else
- objOut.writeline strComputer & vbTab & "no Contact"
- End If
- Loop
- objout.close
- Function Ping(strComputer)
- Dim objShell, boolCode
- Set objShell = CreateObject("WScript.Shell")
- boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
- If boolCode = 0 Then
- Ping = True
- Else
- Ping = False
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement