I've created a python COM class for the current user so it can be used without admin privileges.
I've modified the python win32com.server.register
module to create registry for the current user only instead of all.
The standalone script works fine and COM server gets registered successfully. Here is my script:
import pythoncom, win32com.server.register_current_user
class Python_For_VBS:
_reg_progid_ = 'PythonForVBS.Utilities'
_reg_clsid_ = pythoncom.CreateGuid()
_reg_desc_ = "Python Test COM Server"
_public_methods = ['HelloWorld']
def HelloWorld(self, item=None):
return 'Hello World!'
if __name__ == '__main__':
print('Registering COM server?quo')
win32com.server.register_current_user.UseCommandLine(Python_For_VBS)
But the problem is, I'm not able to use this class with VB CreateObject().
Sub Python_Test
Dim PythonUtils
Dim response
Set PythonUtils = CreateObject("PythonForVBS.Utilities")
response = PythonUtils.HelloWorld()
MsgBox response
End Sub
Can VB only use classes defined for all users? If not, how can I use this class from within a VBScript?
EDIT:
I'm using Python 64-bit and I'm running this VBScript in QlikView. So it does not show any error but the script does not execute and the debugger points to the line which calls CreateObject() function, so I guess that is where the error is.
registry export from HKEY_CURRENT_USER\Software\Classes\PythonForVBS.Utilities
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\PythonForVBS.Utilities]
[HKEY_CURRENT_USER\Software\Classes\PythonForVBS.Utilities\CLSID]
@="{62F16FCC-730A-4CD4-9249-CE1B683AE423}"
registry export from HKEY_CURRENT_USER\Software\Classes\CLSIDPythonForVBS.Utilities
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSIDPythonForVBS.Utilities]
@="Python Test COM Server"