I have changed it all around, but the error does not happen in any of that code, only after it runs through. To test that I did the following.
For $i = 1 to $FilesToRegister[0]
MsgBox(0,"Msg",$i & "-" & 1)
$aCall = DllCall($RegisterPath & $FilesToRegister[$i], "long", "DllUnregisterServer")
MsgBox(0,"Msg",$i & "-" & 2)
If IsArray($aCall) = 1 Then $Msg = $aCall[0]
MsgBox(0,"Msg",$i & "-" & 3)
If IsArray($aCall) = 0 Then $Msg = $aCall
MsgBox(0,"Msg",$i & "-" & 4)
If @error Or $Msg <> 0 Then
MsgBox(0,"Msg",$i & "-" & 5)
WriteLog(1,"UnReg FAILED " & @TAB & $Msg & @TAB & $RegisterPath & $FilesToRegister[$i])
Else
MsgBox(0,"Msg",$i & "-" & 5)
WriteLog(1,"UnReg SUCCESS" & @TAB & "-0000000000" & @TAB & $RegisterPath & $FilesToRegister[$i])
EndIf
MsgBox(0,"Msg",$i & "-" & 6)
Next
So I had a popup on the screen after every step, such as 1-1, 1-2, 1-3, etc. The error happens after 2-1, but before 2-2, meaning it completes a full loop, and happens on the second execution of "$aCall = DllCall($RegisterPath & $FilesToRegister[$i], "long", "DllUnregisterServer")"
Is there something I need to clear at the end of my loop perhaps?