Some Computers Wont restart

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
devereux0110
Posts: 38
Last visit: Mon Oct 02, 2017 7:11 am

Some Computers Wont restart

Post by devereux0110 »

We are using a script to reboot a remote computer.

I can attach a copy of the script if you wish but it is the standard scripting using

Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem"_ & " where Primary=true")

The script works fine 90% on 90% of the computer however the other 10% give an error message
Line: 86
Char: 5
Error: The remote server machine does not exist or is unavailable: 'GetObject'
Code: 800A01CE
Source: Microsoft VBScript runtime error

We have tried updating the service pack and the vbscript engine on these computers with no luck. The computers are completely randam, sometimes, another computer with the same image can start to delevelopment this problem.

Any Ideas gratefully recieved

As I said this script works perfectly on most of the computers.

Thanks
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Some Computers Wont restart

Post by rasimmer »

If objRecordSetEx("mail") <> "" Or Not IsNull(objRecordSetEx("mail")) Then

Well, this could be a couple of things. If you are using a hostname to connect WMI, it could be that the computer is off or DNS doesn't resolve. I typically have it do a test ping before I run WMI because WMI takes it's sweet time to time out.


Code: Select all

Function blnPing(computerName)
    'Set objWSHShell = CreateObject("WScript.Shell")
    Dim objExecObject, strText
    Set objExecObject = objShell.Exec("%comspec% /c ping -n 3 -w 1000 " & computerName)
    Do While Not objExecObject.StdOut.AtEndOfStream
        strText = objExecObject.StdOut.ReadAll()
        If Instr(strText, "Reply") > 0 Then
            blnPing = True
        Else
            blnPing = False
        End If
    Loop
End Function
Function blnPing(computerName)
    Dim colItems, objItem, objWMIPing, propValue
    On Error Resume Next
    Set objWMIPing = GetObject("winmgmts:.rootcimv2")
    Set colItems = objWMIPing.ExecQuery("Select * from Win32_PingStatus Where Address = '" & computerName & "'")
    blnPing = ""
    
        For Each objItem in colItems
            If objItem.StatusCode = 0 Then 
               blnPing = True          
                'strIP = objItem.ProtocolAddress
            Else
            blnPing = False
            End If
       Next
    On Error GoTo 0
End Function

The first function can be used on 2000 or XP, but the WMI method in the second can only be used in XP and above. Basically you would do something like:

Code: Select all

If blnPing(~pass_a_name_or_IP~) = True Then
    'Computer is pinging, run WMI command
Else
    'Computer is not PINGING, log it and go to next computer
End If

You also need to make sure that the Windows Instrumentation Management service is running on the host. If these machines are on, and you can connect to them remotely (which means RPC is working and trust isn't broken), then you can attempt to run a WMI script locally. If it fails, you might have a corrupt WMI issue. In that case, you usually stop the service, clear the repository (C:WINDOWSsystem32wbemRepository) and restart the service. I'm sure if this is the issue, there are a plethora of articles on fixing a corrupt WMI workstation. Hope this helps.

rasimmer2009-03-18 06:15:53
User avatar
devereux0110
Posts: 38
Last visit: Mon Oct 02, 2017 7:11 am

Some Computers Wont restart

Post by devereux0110 »

The laready does a ping test before attempting to restart/logoff/shutdown the computer

I will try the WMI test and repair

The computers involve do run logon and startup scripts with no problems.
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Some Computers Wont restart

Post by rasimmer »

Doing the WBEMTest or just running a WMI script locally will tell you if the problem is with WMI. If either of those work, then it's most likely not WMI corruption but a RPC problem. I've had issues before where the computer's trust was broken with the domain and the workstation had to be readded. You can usually test this by doing a simple file creation on the C:, if it works then the trust and RPC is working, otherwise I would make sure the computer account is squared away on the domain.
User avatar
devereux0110
Posts: 38
Last visit: Mon Oct 02, 2017 7:11 am

Some Computers Wont restart

Post by devereux0110 »

We have just worked out that the computers that wont shut down by script also are not getting Active Directory deployed MSI programs

Does this give any more clues

Thanks
This topic is 15 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked