5 Replies Latest reply on Nov 30, 2011 6:54 AM by Catalysttgj

    sdclient.exe /msg not working on all clients

    Rookie

      I have a vbs script that if no user is logged on, reboots the device and updates the BIOS. If a user is logged on then nothing happens. I have set 2 lines that tell me weather a user is logged on or not using the sdclient.exe /msg.

       

      The package always works, but the message field is left blank on a lot of PCs in the console.On Error Resume Next

      Dim oShell, oshell1, oshell2, oshell3
      Set oShell = WScript.CreateObject ("WScript.Shell")
      Set oShell1 = WScript.CreateObject ("WScript.Shell")
      Set oShell2 = WScript.CreateObject ("WScript.Shell")
      Set oShell3 = WScript.CreateObject ("WScript.Shell")
      'oshell.run "notepad.exe"

      'Get local computer name
      Set wshNetwork = WScript.CreateObject( "WScript.Network" )
      strComputerName = wshNetwork.ComputerName
      'strComputerName = "ComputerABC" 'For testing specific computer

      'Setup WMI calling for logon name and shutdown assignment
      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")

      'Get currently logged on user's username
      Set colComputer = objWMIService.ExecQuery _
          ("Select * from Win32_ComputerSystem")
      For Each objComputer in colComputer
          If IsNull(objComputer.UserName) Then 'If no one is logged on
              strLoggedOn = "No"
      oshell.run "sdclient.exe /msg=Success"
      oshell1.run "UpdateBIOS.vbs"
      oshell2.run "shutdown -r -f -t 60"
          Else
      ' oshell3.run "sdclient.exe /msg=Failed"
      oshell3.run "sdclient.exe /msg=UserLoggedIn-" & objComputer.UserName
              strLoggedOn = "Yes"
          End If
      Next

      'If no one is logged on shut down the computer
      'If strLoggedOn = "Yes" Then
      '    Set colComputer = objWMIService.ExecQuery _
      '        ("Select * from Win32_OperatingSystem")
      '    For Each objComputer in colComputer
      '        objComputer.Win32Shutdown(1)
      'Next
      'End If

        • 1. Re: sdclient.exe /msg not working on all clients
          Catalysttgj Expert

          According to the attached image file it looks like ALL of the devices that were on at the time did return a message. Only two computers in the list didn't have a message but they also show: "Cannot find agent" under the "result" column. Is your image file a good example of what you're actually seeing?

          Did those two devices actually do the work of the script, or were they off perhaps?

          We see "Cannot find agent" a lot where the common base agent is blown up on a device. Usually, either restarting the "LANDesk Management Agent" service helps this, or reinstalling the service either by reinstalling the whole agent or just the common base agent via its MSI located in the LDclient directory.

          If they did run the script, then they simply didn't talk back to the core in time perhaps?

          Maybe the shutdown time wasn't long enough for the message to make it back to the core? (big maybe, 60 should be long enough).

          The other direction is that they didn't run the script or died somewhere in the middle of it.

          You might want to add a log file output to your script that writes locally on the device for further forensic purposes.

          You could then write something to it at each relevant point. That might be useful.

           

          On another note, do any of your devices have Windows XP as the OS?

          If so, how will you overcome "sticky" profiles on these, or does that not occur  in your environment?

          I point out XP only, as I'm under the impression (falsely perhaps), that Microsoft corrected this issue in newer OS's.

          They did add UPHclean 1.6 (at least) to the user profile manager service in Vista and up, so it might not happen on these,

          however in our environment (mostly still running XP), we see a lot of stuck profiles even with UPHclean 1.6 installed and running.

          Given our situation, code such as this is not very successful, so we had to come up with a better way to get the same type of results. (ie. reboots when no user is present.)

          • 2. Re: sdclient.exe /msg not working on all clients
            Rookie

            That may not have been the best screenshot. Under others the status = done, result = no error, but under message it is blank.

             

            I will try added a ping nul command after the message line to give it some time to send the message back to the console.

            • 3. Re: sdclient.exe /msg not working on all clients
              Catalysttgj Expert

              Another thing I'd look at as perhaps just a point of concern about logic in any scripting language; you might want to consider setting the flag in the For Next loop, and move the commands themselves outside of that loop and use the flag to trigger the commands. You might be getting redundant executions by having the commands inside the loop. Just a thought. I think you had that sort of structure in your initial testing, as the commented out section at the bottom of the code suggests.

               

              Just a thought.

              • 4. Re: sdclient.exe /msg not working on all clients
                Rookie

                Thanks, adding a bit of a ping pause of 30 seconds after the message sent back to the console appears to have resolved the issue on most of them, just the odd few not reporting back now which I'm happy with.

                 

                Thanks

                • 5. Re: sdclient.exe /msg not working on all clients
                  Catalysttgj Expert

                  Cool, and interesting outcome. Good to know.

                   

                  You might want to mark this answered, unless you want to get more answers.

                   

                  Cheers,

                  g;-)