开云体育

Issues running LTspice as a batch service


 

I have a python program kicking off LTspice as a background windows process with the following command.
?
process = await asyncio.create_subprocess_exec(LTSPICE_PATH, "-b", "-run", solverFlag, fpath, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
?
I am running this process on a server and when I run it as my user account everything works as expected. Now I need to have it run as a windows service which requires a service account. I set this up and tried running but I get messages that symbols are missing from the simulation. I figured maybe the .ini file in the service account's folder was missing the symbol and library search paths so I made sure to match the .ini file in my service account's AppData/Roaming folder to match the one on my account. Unfortunately this did not help. Does anyone know why running in batch mode as a service account it would fail to look in the search paths?


 
Edited

On Tue, Feb 25, 2025 at 08:32 PM, Jeff Kayzerman wrote:
.... Does anyone know why running in batch mode as a service account it would fail to look in the search paths?
This is only a guess here.? But I suspect you have defined User folders for your symbols and models, which reside in one of your account's folders, perhaps under its "Documents" folder or "AppData" or whatever.? The other account does not have the same folders.? Well, it has the same-named folders but they are distinct for each Windows user.? So it does not see the same library areas.
?
The settings in the .ini file are relative to each Windows account's folders, as managed by MS-Windows.? Windows does a good job of hiding their actual physical locations.
?
Andy
?


 

开云体育

This is a good example in support of the file management strategy of including all symbols (and models and whatnot) that are not part of the LTspice installation in the same directory (folder) as the schematic which uses/invokes them. Doing so ensures that all files that the simulation needs are available to whichever user (or other entity) is going to use the simulation.

Donald.

On 2/25/25 22:08, Andy I via groups.io wrote:

On Tue, Feb 25, 2025 at 08:32 PM, Jeff Kayzerman wrote:
.... Does anyone know why running in batch mode as a service account it would fail to look in the search paths?
This is only a guess here.? But I suspect you have defined User folders for your symbols and models, which reside in one of your account's folders, perhaps under its "Documents" folder or "AppData" or whatever.? The other account does not have the same folders.? Well, it has the same-named folders but they are distinct for each user.? So it does not see the same library areas.
?
The settings in the .ini file are relative to each account's folders, as managed by MS-Windows.? Windows does a good job of hiding their actual physical locations.
?
Andy
?


 

I tried this but now I get this windows error 3221226505


 

开云体育

Did you change your schematic and model references to NOT use the absolute locations?

e.g. use ".include bunchOfModels.mod"

rather than ".include \Home\Users\MyName\MyLibs\bunchOfModels.mod"

A web search on that error (and on the equivalent 0xc0000409) suggests stack overflow in the process; not sure how that might help you, but there it is. FWIW. Most appropriate link I found is whose OP found was a referenced file had an o-umlaut in its name.

Donald.

On 2/26/25 13:49, Jeff Kayzerman wrote:

I tried this but now I get this windows error 3221226505


 

On Wed, Feb 26, 2025 at 01:49 PM, Jeff Kayzerman wrote:
I tried this but now I get this windows error 3221226505
What did you try?
?
And when did you get that error (what were you doing when it happened)?
?
Andy
?


 

I tried putting all the symbols under the same folder as the simulation. Let me try to better describe what I am doing.
?
A python service is polling an AWS message queue for incoming instructions to run a job. The message has the location of a simulation file in AWS S3. Python pulls the .asc file and kicks off LTspice with the provided command line interface using this line of code?
process = await asyncio.create_subprocess_exec(LTSPICE_PATH, "-b", "-run", solverFlag, fpath, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
*NOTE* -b for batch mode, no interactive gui
?
That code kicks off LTspice as an async process. I have a callback function which runs when the process finishes that zips up the output files and places them back into AWS S3. The user is then emailed the status of their job and the location of their files.
?
All of this works great!
?
What isn't working is when I try to run this process as a windows service. The python is running properly but kicking off LTspice results in this error code 3221226505 so I get an email saying "Simulation failed with status code 3221226505".
?
Since there is no descriptive error message I have no idea why everything works fine when I run it while I'm logged in but it won't run as a background service. I need it to run as a background service because the server won't let a user stay logged in indefinitely.


 

On Thu, Feb 27, 2025 at 01:31 PM, Jeff Kayzerman wrote:
What isn't working is when I try to run this process as a windows service. The python is running properly but kicking off LTspice results in this error code 3221226505 so I get an email saying "Simulation failed with status code 3221226505".
Presumably that is a Windows status code.? I think it did not come from LTspice, but it might mean Windows is telling you that LTspice did not exit happily.
?
Can you find what that error code means, if it's from Windows?
?
It's curious that the message states "Simulation failed ...".? Where did that word "Simulation" come from?
?
Did LTspice create a .LOG file?? What does it say?
?
Since there is no descriptive error message I have no idea why everything works fine when I run it while I'm logged in but it won't run as a background service. I need it to run as a background service because the server won't let a user stay logged in indefinitely.
I am unfamiliar with running programs in a Windows background service.? Is it possible that a background service does not "see" itself with a normal default directory?? Is it a mirror of the right directory, including all contents?? What about its environment variables?? Does it see the LTspice .ini file too?
?
I'm assuming that everything works now that you moved all the symbols (and models too?) into the same folder with the schematic, when run normally.? I think that is what you said.
?
Andy
?


 

On Thu, Feb 27, 2025 at 10:31 AM, Jeff Kayzerman wrote:
I tried putting all the symbols under the same folder as the simulation. Let me try to better describe what I am doing.
?
A python service is polling an AWS message queue for incoming instructions to run a job. The message has the location of a simulation file in AWS S3. Python pulls the .asc file and kicks off LTspice with the provided command line interface using this line of code?
process = await asyncio.create_subprocess_exec(LTSPICE_PATH, "-b", "-run", solverFlag, fpath, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
*NOTE* -b for batch mode, no interactive gui
?
That code kicks off LTspice as an async process. I have a callback function which runs when the process finishes that zips up the output files and places them back into AWS S3. The user is then emailed the status of their job and the location of their files.
?
All of this works great!
?
What isn't working is when I try to run this process as a windows service. The python is running properly but kicking off LTspice results in this error code 3221226505 so I get an email saying "Simulation failed with status code 3221226505".
?
Since there is no descriptive error message I have no idea why everything works fine when I run it while I'm logged in but it won't run as a background service. I need it to run as a background service because the server won't let a user stay logged in indefinitely.
?
Suggestion..
?
Create a batch or command file and run a command within it, so it gets the windows environment variables while running as a service.
Redirect the results to a file. It might be telling....
?


 

Yes it is a windows error, something about a stack buffer overrun, not sure what to make of that. The message "Simulation failed with status code <status code>" Is my code in the except block of the python program. There is no log file that gets created from LTspice.


 

Convert the error number to hex.
Then Google is your friend.
The Windows error code 0xc0000409 is a software exception error that can occur when an application is installed incorrectly

?
?
Sent:?Thursday, February 27, 2025 at 1:54 PM
From:?"Andy I via groups.io" <AI.egrps+io@...>
To:[email protected]
Subject:?Re: [LTspice] Issues running LTspice as a batch service
On Thu, Feb 27, 2025 at 01:31 PM, Jeff Kayzerman wrote:
What isn't working is when I try to run this process as a windows service. The python is running properly but kicking off LTspice results in this error code 3221226505 so I get an email saying "Simulation failed with status code 3221226505".
Presumably that is a Windows status code.? I think it did not come from LTspice, but it might mean Windows is telling you that LTspice did not exit happily.
?
Can you find what that error code means, if it's from Windows?
?
It's curious that the message states "Simulation failed ...".? Where did that word "Simulation" come from?
?
Did LTspice create a .LOG file?? What does it say?
?
Since there is no descriptive error message I have no idea why everything works fine when I run it while I'm logged in but it won't run as a background service. I need it to run as a background service because the server won't let a user stay logged in indefinitely.
I am unfamiliar with running programs in a Windows background service.? Is it possible that a background service does not "see" itself with a normal default directory?? Is it a mirror of the right directory, including all contents?? What about its environment variables?? Does it see the LTspice .ini file too?
?
I'm assuming that everything works now that you moved all the symbols (and models too?) into the same folder with the schematic, when run normally.? I think that is what you said.
?
Andy
?


 

On Thu, Feb 27, 2025 at 11:15 AM, Jeff Kayzerman wrote:
Yes it is a windows error, something about a stack buffer overrun, not sure what to make of that. The message "Simulation failed with status code <status code>" Is my code in the except block of the python program. There is no log file that gets created from LTspice.
?
You'll need to launch the python LTspice subprocess in the context of the target user and target schematic source folder.


 

Thank you, the application is clearly installed correctly though because it works when not running as a service


 

I believe I am doing this


 

开云体育

I thought that the advice was that it was not installed in the right place, but I might be wrong.'Not installed correctly' might be a paraphrase of 'I can't open it'.

On 2025-02-27 19:59, Jeff Kayzerman wrote:
Thank you, the application is clearly installed correctly though because it works when not running as a service
--
OOO - Own Opinions only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

The Windows error code 0xc0000409 is a software exception error that can occur when an application is installed incorrectly
So, does this mean the Windows service account does not know what LTspice is, or where to find it?
?
Sorry, I don't know snakes.
?
Andy
?


 

FYI for anyone who comes next, I got it working with spicelib and passing a .net file instead of a .asc file. It might work with the normal cli passing a .net file as well but I'm too lazy to go back and try now that I have it working with spicelib


 

Ok I tried it with a normal windows process leveraging the cli (not spicelib) and it works. So the entire problem was passing a .asc instead of a .net file.


 

On Tue, Mar 11, 2025 at 11:11 AM, Jeff Kayzerman wrote:
Ok I tried it with a normal windows process leveraging the cli (not spicelib) and it works. So the entire problem was passing a .asc instead of a .net file.
?
?
Can you share the command parameters that you used?