I'm really sorry about not following the proper etiquette. I'm new to this. What do you mean by code tags? Do you mean tabs. I tried to put in tabs for clarity, but when you submit the message the tab spaces disappear.

Here is the script I am running along with how I call the UDF. I tested it with only the code below and it give the same error so I know it's something below and not any of the other code in my script.

----------------------------
SETOPTION("Wow64FileRedirection","off")
CALL "ENUMPROCESS.kix"
$STICK=EnumProcess("stick.exe")
IF $STICK = 0
RUN "C:\Program Files\Stick\Stick.exe"
ENDIF

Here is the function
----------------------------------
FUNCTION EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id, $getobject, $
if not $computer $computer=@wksta endif
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
select
case val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$EnumProcess = $Process.name
next
$GetObject=''
case vartype($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For each $Process in $GetObject
if $terminate $=$Process.Terminate endif
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=left($EnumProcess,len($EnumProcess)-1)
$GetObject=''
case 1
exit 1
endselect
ENDFUNCTION