You may have noticed that the DCOM configuration dialog states “Client applications may override your selection.” So when you configure DCOM, you really just provide default values for non-DCOM-aware programs. In fact, if you want to make your client code DCOM-aware, it isn’t necessary to configure DCOM on the local machine at all; your client code provides the information needed.
To demonstrate this, let’s restore the DCOM configuration on
the local machine to the defaults. Restart the DCOM configuration
tool and again select the
object. Select the Location tab and restore the settings to how you
first found them. The dialog should look similar to Figure 12.8.
Select the OK button to apply the changes.
First, let’s check that the object is indeed restored correctly. Execute the same lines of code used previously, but because the DCOM configuration has been restored, the object should be local:
>>> i=win32com.client.Dispatch("Python.Interpreter", clsctx=clsctx) >>> i.Exec("import win32api") >>> i.Eval("win32api.GetComputerName()") 'BOBCAT' >>>
As expected, the local machine name is now being used, and you should be able to locate a pythonw.exe process running on the local computer.
win32com.client.DispatchEx() function allows you to override the DCOM ...