Chris
I think you know this but there are other ways to get the output parameters. I assume there is a similar function to this one in the UDF section. This is why I have not given up yet.Code:
FUNCTION fnProcessRun($ProcessCommand, $WMIComputerName, OPTIONAL $ProcessHidden, OPTIONAL $ProcessStartDir)
;--- This will start a process on a computer.
IF $ProcessHidden
$objProcStart = $WMIComputerName.Get("Win32_ProcessStartup")
$ProcStartInst = $objProcStart.SpawnInstance_
$ProcStartInst.ShowWindow = "0"
$procStartInst.Put_
ENDIF
$objProc = $WMIComputerName.Get("Win32_Process")
$objProcInst = $ObjProc.Methods_("Create").InParameters.SpawnInstance_
$objProcInst.CommandLine = $ProcessCommand
IF $ProcessStartDir
$objProcInst.CurrentDirectory = $ProcessStartDir
ENDIF
IF $ProcessHidden
$objProcInst.ProcessStartupInformation = $ProcStartInst
ENDIF
$objProcOut = $WMIComputerName.ExecMethod("Win32_Process","Create",$objProcInst)
$fnProcessRunError = @Error
$fnProcessRun = $objProcOut.Processid
; $pid = $objProcOut.Processid
; $owner = $WMIComputerName.Get("Win32_Process=$pid").ExecMethod_("GetOwner")
;? "Process " + $pid + " was created by " + $owner.domain + "\" + $owner.user + "."
EXIT $fnProcessRunError
ENDFUNCTION
_________________________
Kelly