You are not far off.

Be aware that there is a UDF (user defined function) in the UDF forum which will do all the work for you.

This is a test example which works on my XP pro system:
 Code:
Break ON
   
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")
$=SetOption("ASCII","ON")
   
Global $oWMIService
Dim $oProcess,$colProcess
 
If Not IsDeclared($Host) Global $Host EndIf
 
If $Host="" $Host=@WKSTA EndIf
 
$oWMIService = GetObject("winmgmts:\\"+$Host+"\root\cimv2")
If @ERROR "Cannot access WMI sevrice, error is " @ERROR ": " @SERROR ?  Exit @ERROR EndIf
$colProcess=$oWMIService.ExecQuery('Select * from Win32_Process',,48)
If @ERROR "Cannot access WMI sevrice, error is " @ERROR ": " @SERROR ?  Exit @ERROR EndIf

For Each $oProcess In $colProcess
	"Process: "+$oProcess.Name+@CRLF
Next
 
Exit 0