[python-win32] Create simple COM server without admin permissions?

Habibullah Aslam haslam555 at gmail.com
Fri May 15 22:32:04 EDT 2020


Hi,

I'm new to pythoncom and I'm just trying to create a basic COM server in
Python3 that I can ping from a client. I've been able to create a COM
server successfully using the info at
http://timgolden.me.uk/pywin32-docs/html/com/win32com/HTML/QuickStartServerCom.html#Registering,
but this requires Admin permissions which I don't have access to on my work
computer.

I was hoping someone could clarify what I need to modify so that I can
register the server without raising admin permissions? (I'm aware that it
is possible to write to the HKCU registry without admin permissions, though
I'm not sure how that would fit in with the basic server code.)

Here's my basic server:

    import pythoncom
    import win32com
    from win32com.server.util import wrap

    _reg_clsid_ = "{6B39CAA1-A320-4CB0-8DB4-352AA81E460E}"

    class ActiveObject:
        _public_methods_ = ["ping"]

        def ping(self):
            return "1"

    if __name__ == "__main__":
        ob = win32com.server.util.wrap(ActiveObject)
        handle = pythoncom.RegisterActiveObject(ob, _reg_clsid_, 0)
        print(handle)

And here's the client:

    import win32com.client
    server =
win32com.client.Dispatch("{6B39CAA1-A320-4CB0-8DB4-352AA81E460E}")
    print(server.ping())

Let me know if you need any additional information. (As an aside, I'm also
fine with using AutoHotkey to help register the server in the registry if
that's needed.)

I've posted a question on StackOverflow if it helps:
https://stackoverflow.com/questions/61811297/how-to-create-a-python-com-server-without-admin-permissions


Thank you for any input
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20200515/a363cc60/attachment.html>


More information about the python-win32 mailing list