Ok found the real issue with tons of testing and help from Thomas Baird (Thanks Tom):
ok I take back what I said it is not the agent itself but a line of code I ran before the wmic commands.
This query fails the wmic commands later on:
SC query AeXNSClient | FIND "STATE" | FIND "RUNNING" >> c:\RISlog\Deployment.log 2>&1
When I Uninstalled the agent a precheck for the agent prevents the above command from running. Running the command against a different service produces the same hanging result. So what we found is it is due to the logging of that command.
remove "2>&1" from the SC command and wmic does not hang later.
So here is test code that fails:
SC query AeXNSClient | FIND "STATE" | FIND "RUNNING" >> c:\RISlog\Deployment.log 2>&1
WMIC EXIT >> c:\RISlog\Deployment.log 2>&1
wmic ComputerSystem Get model >> c:\RISlog\Deployment.log
end
This commands works:
SC query AeXNSClient | FIND "STATE" | FIND "RUNNING" >> c:\RISlog\Deployment.log
WMIC EXIT >> c:\RISlog\Deployment.log 2>&1
wmic ComputerSystem Get model >> c:\RISlog\Deployment.log
end
Hopefully this can help someone else!!! If anyone has an explanation I would sure be interested!