From lee at dximg.com Sun Jun 2 15:32:19 2024 From: lee at dximg.com (Lee Duncan) Date: Sun, 02 Jun 2024 19:32:19 +0000 Subject: [python-win32] servicemanager could not be loaded Message-ID: Hello Python-win32 mailing list: I just figured out my problem and wanted to share for anyone else. On a normal install of Python 3.12 using pip to install pywin32 I was getting "servicemanager.__file__ could not be loaded " pretty much no matter what I did. The message in event viewer was "RuntimeError: servicemanager.__file__ could not be loaded - win32 error code is 193 ". After adding everything to the System Paths I eventually got an error message indicating could not load from "c:\program" on the command line. Which lead to a memory I have of why I always installed python to c:\python312 ( or whatever ). I uninstalled python, reinstalled it to the directory without spaces and everything works great. I don't know if it is PythonService.cpp isn't parsing the space in here: Py_Initialize(); module = PyImport_ImportModule("servicemanager"); if (!module) goto failed; f = PyObject_GetAttrString(module, "__file__"); Py_DECREF(module); if (!f) goto failed; or if it's somewhere in the ServiceManger.pyd. I'm not entirely sure how to track down where it's not parsing the space, but this is a good work around. Lee Duncan -------------- next part -------------- An HTML attachment was scrubbed... URL: From v.popovec at gmail.com Fri Jun 28 05:38:23 2024 From: v.popovec at gmail.com (Viliam Popovec) Date: Fri, 28 Jun 2024 11:38:23 +0200 Subject: [python-win32] Open Excel in Background using Task Scheduler Message-ID: Hello, I have a Windows VM running in Azure cloud, which is connected to File Shares. I have created a Python script which downloads the excel files from the file shares, executes macros and copies the files back. I am able to get this working with a "foreground" task, i.e. launching the script when logged on. However I need to automate launching of the script in case that the VM is restarted, for this I am using Task Scheduler. Task Scheduler works when running in the foreground, but when I select the option "run whether user is logged on or not" I receive the following error pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Microsoft Excel cannot access the file 'C:\\AMS\\temp_dir\\Auftragsnummernliste.xlsm'. There are several possible reasons:\n\n? The file name or path does not exist.\n? The file is being used by another program.\n? The workbook you are trying to save has the same name as a currently open workbook.", 'xlmain11.chm', 0, -2146827284), None) from this line of code excel_macro.Workbooks.Open(Filename=file_path, ReadOnly=1) Is there a way to open the excel file in the background or do I have to find some other workaround (e.g. alerting the admin that the VM was restarted). -------------- next part -------------- An HTML attachment was scrubbed... URL: