Shivam Thakur
Shivam Thakur

Reputation: 21

Python cannot open Excel instance on windows server when remote connection to admin account is disconnected

I have a NodeJS application/website running on a Windows Server. This application is used as a GUI to trigger Python scripts. The python scripts open up excel instances and perform some transformations which could not be done with libraries such as openpyxl. I am using the win32com library. I access the admin user on the windows server using remote desktop, and the entire system works perfectly when the admin user is logged in.

When the remote connection to the admin user is disconnected, I am able to access the website and call python scripts, but they only seem to work till the code reaches the point where it tries opening up the excel instance and I get the following error message.

I am running NodeJS as a service with the admin credentials. I have tried changing the DCOM settings for Excel, but nothing seems to help.

_GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) During handling of the above exception, another exception occurred: 
        
Traceback (most recent call last):
File "C:\Projects\Pythonscripts\LM1.py", line 895, in 
   xl = win32com.client.Dispatch('Excel.Application') 
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\__init__.py", line 117, in Dispatch dispatch, 
   userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName 
   return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
   IDispatch = pythoncom.CoCreateInstance( pywintypes.com_error: (-2147467238, 'The server process could not be started because the configured identity is incorrect. Check the username and password.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
  IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Projects\Pythonscripts\LM1.py", line 897, in
   xl = win32com.client.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\gencache.py", line 618, in EnsureDispatch
   disp = win32com.client.Dispatch(prog_id)
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\__init__.py", line 117, in Dispatch dispatch, 
   userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
   return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\panzer\AppData\Roaming\Python\Python310\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
   IDispatch = pythoncom.CoCreateInstance( pywintypes.com_error: (-2147467238, 'The server process could not be started because the configured identity is incorrect. Check the username and password.', None, None)

Upvotes: 2

Views: 64

Answers (0)

Related Questions