How to Check Process on Windows

I am helping a user set up a backup system. The software I use does not support SFTP by default. It only supports FTP. Using an external program called  Tunnelier, I were able to use the FTP-to-SFTP feature to backup files on a SFTP server. The problem is that I have to make sure Tunnelier is running before I do backup.

The first approach is a simple batch script. Here is the batch file.

@ECHO off

tasklist.exe > tasks.txt

FIND "Tunnelier.exe" tasks.txt
IF ERRORLEVEL 1 Call "C:\Program Files (x86)\Bitvise Tunnelier\Tunnelier.exe" -loginOnStartup

It uses tasklist to list all the processes on the system and write the results to the file tasks.txt. It then uses FIND command to search for Tunnelier.exe string in the text file. If it cannot find it, than it invokes Tunnelier.exe. Note that tasklist.exe is a built-in command for Windows XP and above. If you are still using Window 2000 or 98, you need to use some other programs.

I tested the batch file several times and when I was ready to incorporate it to the backup program. I ran into another problem. The backup program can only run an external executable, not a batch file. So, the batch file is useless.

My second try is AutoIt. I have used AutoIt for automating the process of installing software. It is also a scripting language, but it can be compiled to an executable file. The AutoIt version is even simpler.

If Not ProcessExists("Tunnelier.exe") Then
    ShellExecute("C:\Program Files (x86)\Bitvise Tunnelier\Tunnelier.exe", "-loginOnStartup")

Be the first to comment

Leave a Reply

Social Widgets powered by

Advertisment ad adsense adlogger