Ok thats fair - then I would make the following changes ...
Code:
Function ChangeVLKey($VOL_PROD_KEY)
Dim $obj, $objects, $result
;Key is without hyphens (ABCDEFGHIJKLMNOPQRSTUVWXY)
$objects = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("win32_WindowsProductActivation")
$ChangeVLKey = @error
For Each $obj in $objects
$result = $obj.SetProductKey($VOL_PROD_KEY)
$ChangeVLKey = @error
Next
EndFunction
Basically adding this line after the GetObject:
$ChangeVLKey = @error
This statement kills two birds with one stone
1) It initializes the return code to "something", which it wasn't doing before
2) It will catch a failure on the GetObject and return the code.