Batch file – looking for one-liners?
Hi everyone
please give a quick tip (one-liner if possible).
- A program runs on a server under msaccess – all day, 24/7
- There are reasons why the process might crash. One example is when the server reboots for updates or when the VPN fails to maintain the connection (rare, but it does happen).
- I would like to restart the program – everything is already prepared and working.
What single or multi-line command can I use to check (e.g. once a day in the timer – would work) whether the thing is running.
I haven't done any Windows batch work in a long time. On Linux, I would simply do:
ps -ef | grep msaccess
RC=$?
and then restart the program depending on the RC / return code
This must work under Windows too.
You will be able to and must adapt the path to the installation of Access.
PowerShell would be more up-to-date. But if you want to use the outdated can shell….
Hey, cool. It’s just like Linux. Thank you.
That’s exactly what I was looking for.
Because of Powershell etc – the programs have been running in the background for years – yes, you could change them, question is: what would you have?
a bit faster, the searched program would already be specified in tasklist as a filter. This will let the tasklist capture the parameters of the programs and send them to the pipeline. Finding needs less to analyze accordingly.
@Xandros0506 has already delivered the single liner.
If you want to save the occasional manual input, you can also run a small batch which automatically checks at certain time intervals whether the desired process (yet) is running and if necessary performs the necessary measures.
whatchProcess.cmd
Of course, a ProcessWatscher in PowerShell would be much more efficient…