Scheduled Task to Ensure that a Windows Service is Running

Windows Server logo

Some applications running under Windows services do not always remain in the running state, even when there is no apparent reason that they should stop. This is often due to a bug in the application, or perhaps the connection with the database that was being used by the application was temporarily broken.

In my case, a third-party application that I support (with no control over its source code) has a service that stops without warning to the user from time to time. Regardless of the reason as to why the stop control was sent by the application, the service needs to be running all the time. If this service were stopping due to a crash in the service, Windows has options in the services dialog box that can automatically restart a crashed service, or restart the server itself. These options do not help me, as it is the application sending a stop command to the service. I needed a simple way to ensure that the service is always running. The following batch file, using the actual Service Name (not the Display Name) of the service in place of “ServiceName”, will start the service if it is not running, and do nothing otherwise.

@ECHO OFF
FOR /F "tokens=3 delims=: " %%H IN ('SC QUERY "ServiceName" ^| FINDSTR "        STATE"') DO (
  IF /I "%%H" NEQ "RUNNING" (
   NET START "ServiceName"
  )
)

By saving this as a batch file and setting up a Scheduled Task to run the file on a regular interval such as every five or ten minutes, this will minimize the necessity of manually restarting the service when it is shut down unintentionally, that is, without the intention of the application administrator. The task should be disabled when one needs to have the service shut down for maintenance or troubleshooting.

Focusing on Big Data This Year with Hadoop, R, and Python

big data

This year I plan to focus on learning more about “Big Data” and its related technologies, such as machine learning. Currently, I’m planning on studying Hadoop, R, and Python. What other technologies do you think should be added to this list?

Exporting Data from Lotus Notes Databases

Exporting from Lotus Notes

Lotus Notes was innovative and, by most accounts, a great collaboration software in its heyday. Though there are still some 35 million users of Notes, there are regular rumors of its imminent demise.

Because of this, some organizations that have used Notes over the years may want to move to some other system, such as SharePoint. Getting data out of Notes for reporting or for use in a different system is not very straightforward, as there are several options depending on your needs.

The first is to connect Notes to SQL, which I covered back in June 2012.

Exporting from Lotus Notes
Exporting from Lotus Notes

Another is to export the data into Lotus 1-2-3, and then into Microsoft Excel, if need be. This is problematic for many Excel users today, as you cannot open Lotus 1-2-3 files with versions of Excel newer than Excel 2003.

Exporting view data into a comma separated value (.csv) file is another option. I have read that this particular option does not always work exactly right, especially if there are commas or some other special characters in the data, so YMMV.

The main problem with all of the above options is that you can only export data shown in a particular view with these methods. Unless you want to create (or already have) a view that has all document fields in the view, you won’t be able to see them all. If you want to export all the data in each document, you must export documents into what is called “Structured Text”.

Structured Text, while readable by text editors, cannot be directly imported into CSV or other formats using only Word or Excel. However, some tools been developed for this purpose. One example of such a tool is the Structured Text Parser (STP) written by James J. Schwaller. Tools such as these will make converting data from Lotus Notes into other formats or for use in other systems much simpler, and will not require hiring contractors or buying expensive tools that you will not need once your data is converted.

Good luck!