Try
code:
$a=GetObject('winmgmts:{impersonationLevel=impersonate, (Shutdown)}!\\.\root\cimv2').
ExecQuery('Select * from Win32_ComputerSystem')
? 'Error '+@ERROR+' - '+@SERROR
For Each $b In $a
If $b.UserName=""
$c=Shutdown('','',0,0,1)
EndIf
Next
$a=0

However, for better error control, I'd rather first create the object to see whether the permissions are correct, then apply the WQL query on the object.

See also the FAQ Forum under fnWMILoggedIn() - Retrieves users/computers connected to a computer and fnWMIShutdown() - LogOff/reboot/shutdown a user/computer locally or remotely

[ 03. July 2003, 15:06: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.