I have a script that re-calculates an Excel file using win32api. It works without errors.
When I try to run the same script remotely through pywinrm, I get an error:
Error: com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Sorry, we couldn't find test1.xlsm. Is it possible it was moved, renamed or deleted?", 'xlmain11.chm', 0, -2146827284), None)
What can be the problem?
import winrm
host = 'myhost'
domain = 'mydomain'
user = 'myuser'
password = 'mypassword'
session = winrm.Session(host, auth=('{}@{}'.format(user,domain), password), transport='ntlm')
result = session.run_ps('python script.py')
script.py on remote machine
import win32com.client
xlapp = win32com.client.DispatchEx("Excel.Application")
xlapp.Visible = True
path = "C:\\Users\\MyUser\\Desktop\\excel\\test_file.xlsx"
wb = xlapp.Workbooks.open(path)
The file exists on this path. It can be read via open('path', rb)
. If I run the same code on a remote machine (without winrm, manually), there is no problem.