????

You REALLY need to look at my fMsg UDF!! \:D You're working WAY too hard to put text in a file..

No frills log method:
 Code:
$ = RedirectOutput($INSTALLDIR + '\Debug_LS.txt')
@DATE + ' ' + @TIME + ': ' + @ERROR + ' / ' + @SERROR 
$ = RedirectOutput('')
The fMsg UDF takes that basic concept and puts it into a UDF, which allows you to display and/or log messages; timestamp logged messages; display/log only when Debug mode is active, etc..
 Code:
Global $MSG_LOG_, $DEBUG
$MSG_LOG_ = $INSTALLDIR + '\Debug_LS.txt'
$DEBUG = 1
;
; your code...
;
; write the debug message only to the log, only if DEBUG is enabled
fMsg('Result of WMIQuery: + @ERROR + ' / ' + @SERROR, ''. 0, 20)
The latest versions of all my UDFs are PostPrepped nightly and published on my web site. Many are posted here, but the freshest copies are always at http://www.innotechcg.com.

Anyway - figures that it won't fail when you need it to. If you're doing conditional queries like you show, and only a few, WMIQuery is probably OK. I'd be concerned if you were gathering a half-dozen or more values for use or display. This is where a more custom solution would be beneficial.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D