It's because COM security is set differently in each process. This is determined in each process by the startup call to CoInitializeSecurity
.
A DLL cannot reset this once it has been called, but can set security for the current Wbem connection with CoSetProxyBlanket
.
I couldn't easily figure out how to set this correctly through WbemScripting so I reimplemented with COM calls, much like the extensive example here, only without step 2:
http://msdn.microsoft.com/en-gb/library/windows/desktop/aa390423(v=vs.85).aspx