![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Weird script issues "Phyxious" <Phyxious@xxxxxx> wrote in message news:7DC77019-6E19-47E4-A23F-EBB99D02F85C@xxxxxx Quote: >I am having a few issues that I am unsure of. When running my script >against > remote machines I always use IP Address. For some reason on some machines > I > will get remote server does not exist, even though I can ping it. If I use > the host name it will work or for some it still fails. Any idea why this > would be? > > My next issue is on a few machines I have a WMI query accessing the > Win32_ComputerSystem class. When retrieving the UserName property, it will > return NULL even though there is a user logged in. Why is this? > > Any help is greatly appriciated. Thank you. Next" an error can be raised and all you see is that a Null is displayed. The script may fail to attach to the remote computer because of error, firewall, DCOM disabled, a problem with WMI, etc. If you use "On Error Resume Next", comment it out. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Weird script issues I can not find the machine that was causing this issue so I can not give you the exact error that was occuring. But here is portion of my code: sComputer = InputBox("Enter IP Address", "IP Address", "150.142.") Set oWMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" & sComputer & "\root\cimv2") 'On Error Resume Next ' Call Win32_ComputerSystem class to get information about the pc Set cComputerSystem = oWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") ' Loop through the collection and store data in variables For Each oComputerSystem In cComputerSystem With oComputerSystem If InStr(.Manufacturer, "Hewlett") > 0 Then sProductNumber = ProductNumber(sComputer) sManufacturer = "HP" sModel = Mid(.Model, InStr(.Model, "Compaq"), 13) Else sManufacturer = "Dell" sModel = .Model End If aUserName = Split(.UserName, "\") sPCName = .Name End With Next sDomain = aUserName(0) sUserName = aUserName(1) It would fail at the line aUserName = Split(.UserName, "\") because ..UserName is NULL. Now at the time I ran the script I verified that a user is logged on by using SysInternals psloggedon application, so really I do not understand why it would come back NULL "Richard Mueller [MVP]" wrote: Quote: > > "Phyxious" <Phyxious@xxxxxx> wrote in message > news:7DC77019-6E19-47E4-A23F-EBB99D02F85C@xxxxxx Quote: > >I am having a few issues that I am unsure of. When running my script > >against > > remote machines I always use IP Address. For some reason on some machines > > I > > will get remote server does not exist, even though I can ping it. If I use > > the host name it will work or for some it still fails. Any idea why this > > would be? > > > > My next issue is on a few machines I have a WMI query accessing the > > Win32_ComputerSystem class. When retrieving the UserName property, it will > > return NULL even though there is a user logged in. Why is this? > > > > Any help is greatly appriciated. Thank you. > We may need to see the script. For example, if you use "On Error Resume > Next" an error can be raised and all you see is that a Null is displayed. > The script may fail to attach to the remote computer because of error, > firewall, DCOM disabled, a problem with WMI, etc. If you use "On Error > Resume Next", comment it out. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Weird script issues "Phyxious" <Phyxious@xxxxxx> wrote in message news:048E1ED5-3E47-4551-AED3-3FE9C67BE812@xxxxxx Quote: >I can not find the machine that was causing this issue so I can not give >you > the exact error that was occuring. But here is portion of my code: > > sComputer = InputBox("Enter IP Address", "IP Address", "150.142.") > Set oWMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\" > & > sComputer & "\root\cimv2") > 'On Error Resume Next > ' Call Win32_ComputerSystem class to get information about the pc > Set cComputerSystem = oWMIService.ExecQuery("SELECT * FROM > Win32_ComputerSystem") > > ' Loop through the collection and store data in variables > For Each oComputerSystem In cComputerSystem > With oComputerSystem > If InStr(.Manufacturer, "Hewlett") > 0 Then > sProductNumber = ProductNumber(sComputer) > sManufacturer = "HP" > sModel = Mid(.Model, InStr(.Model, "Compaq"), 13) > Else > sManufacturer = "Dell" > sModel = .Model > End If > > aUserName = Split(.UserName, "\") > sPCName = .Name > End With > Next > > sDomain = aUserName(0) > sUserName = aUserName(1) > > It would fail at the line aUserName = Split(.UserName, "\") because > .UserName is NULL. Now at the time I ran the script I verified that a user > is > logged on by using SysInternals psloggedon application, so really I do not > understand why it would come back NULL > is logged into the computer. I assume that you get a value for sPCName, so you know that the script successfully connected to the remote computer. If so, that means you can retrieve .Name but not .UserName, which cannot be explained. Since in general you will not know if someone is logged in (or you wouldn't be retrieving .UserName) it would make sense to check for the Null condition. Perhaps similar to: ========== With oComputerSystem sName = .UserName If Not IsNull(sName) Then aUserName = Split(sName, "\") sDomain = aUserName(0) sUserName aUserName(1) Else sDomain = "none" sUserName = "none" End If End With ======= I did not bother to check if UBound of aUserName is greater than 0, as in my tests there is always a "\" in the value of .UserName, even if the user is local. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- End With |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Some Weird Desktop Shortcut Icon Issues | General Discussion | |||
| Weird CPU usage and memory allocation issues... | General Discussion | |||
| Re: Weird script issues | VB Script | |||
| Weird Connection Issues | Vista mail | |||
| Weird RAM Issues | General Discussion | |||