Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Tips And Tricks How To Check And Start An Application If It Is Not Running In Windows

How To Check And Start An Application If It Is Not Running In Windows

I will provide a VB Script that will check and start an application (or process) if it is not running. And I will show How to create a Windows Task Scheduler that automatically calls the VB script every few minutes.

It is applied properly on Windows Vista, Windows 7 or Windows Server 2008. I haven’t tested on Windows XP or Windows Server 2003.

1. VB Script start an application if it is not running

Download the VB Script (Failsafe.vbs) and update strEXEFileName and strEXEFilePath with your application file name and its path.

The VB Script content:

Dim objWMIService, colItems, objItem, strComputer, strFlashEXEFile
Dim count
 
strEXEFileName = "your-application-name.exe"
strEXEFilePath = "D:/path-to-your-app/" & strEXEFileName
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.InstancesOf("Win32_Process")
 
count = 0
 
For Each objItem In colItems
	If objItem.Name = strEXEFileNameThen
		count = count + 1
	Else
	End If
Next
 
Set objWMIService = Nothing
Set colItems = Nothing
 
If count = 0 Then
 
	Dim oShell
	Set oShell = WScript.CreateObject ("WScript.Shell")
	Return = oShell.run(strEXEFilePath,3, false)
	Set oShell = Nothing
 
End If

Dim objWMIService, colItems, objItem, strComputer, strFlashEXEFile Dim count strEXEFileName = "your-application-name.exe" strEXEFilePath = "D:/path-to-your-app/" & strEXEFileName strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.InstancesOf("Win32_Process") count = 0 For Each objItem In colItems If objItem.Name = strEXEFileNameThen count = count + 1 Else End If Next Set objWMIService = Nothing Set colItems = Nothing If count = 0 Then Dim oShell Set oShell = WScript.CreateObject ("WScript.Shell") Return = oShell.run(strEXEFilePath,3, false) Set oShell = Nothing End If

2. Create Task Schedule To Run The Script every 10 minutes automatically

Create a new Schedule Task by doing following steps below:

  • 1. Start => All Programs => Accessories => System Tools => Task Scheduler.
  • 2. Click the Action menu, and then click Create Task.
  • 3. In the General tab, type a name for the task and an optional description.
  • 4. Go to Triggers tab then click on New button to create a schedule to run the task.
  • 5. In the New Trigger box, select Daily radio button and check on Repeat task every … option to determine How often we would like to check the app.

    Let’s say Repeat task every 10 minutes:

    Windows Task Schedule Repeat Task Settings

    Windows Task Schedule Repeat Task Settings

    Then click OK to finish this step.

  • 6. Go to Actions tab and click New. In the New Action box, select Start a program in the Action drop down list, and then Browse to the VB Script (Failsafe.vbs) similar to image below:
    Windows Task Schedule Start A Program

    Windows Task Schedule Start A Program

  • 7. Click OK to finish this step.
Sep 15, 2011Hoan Huynh
Free Test Upload Speed And Download Speed ServiceDisable Pingbacks and Trackbacks In WordPress
You Might Also Like:
  • Auto Delete Old IIS Logs, FTP Logs, SMTP Logs In Windows
  • Call Or Open a web page url by using Windows Task Scheduler or CronJob
  • How To Check Which Stored Procedures Or SQL Commands Are Running On SQL Server
  • Schedule Backup And Zip MySQL Database In Windows
  • Check Up Time In Windows Server 2008 – 7 – Vista – XP
  • How To Check A Port Is Open Or Blocked In Windows
  • Sphinx Windows could not start the SphinxSearch service on Local Computer
  • Install ASP On Microsoft Windows Server 2008 IIS 7.0 and IIS 7.5
  • How To Enable Telnet Command In Windows 7 And Server 2008
  • Setup Free SSL Certificate For Testing On Development Environment In Windows IIS 7
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago Tips And TricksHow To, Task Scheduler, VB Script, Windows1,603
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,455 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,836 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,652 views
JQuery Allow only numeric characters or only alphabet characters in textbox
14,986 views
C# Read Json From URL And Parse/Deserialize Json
11,719 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development