On Error Resume Next ' continue on Error strquery = "Select * from Win32_OperatingSystem where Primary=true" Set objOS=GetObject("winmgmts:{(Debug,RemoteShutdown)}//./root/cimv2").ExecQuery(strQuery) If Err > 0 Then WScript.Quit (100) 'Force Logoff For each oOS in objOS oOS.Win32Shutdown(4) Next On Error goto 0 'Release objects Set oOS = Nothing Set objOS = Nothing