how to detect if a program is run for example firefox.exe, if firefox is run, a message box will appear but if i rename firefox.exe into aw.exe, how could i know if it is firefox?
here is a simple script that will check if firefox.exe is running, if so it will stop ... Code: Set WshShell = WScript.CreateObject ("WScript.Shell") Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process") '============================================================================================== For Each objProcess in colProcessList If objProcess.name = "firefox.exe" then vFound = True End if Next If vFound = True then WshShell.Run ("C:\Windows\system32\cmd.exe") WshShell.sendkeys "taskkill /IM firefox.exe" WshShell.SendKeys "{ENTER}" Else Msgbox("Not Installed") End If
or another way call from a bat file is; Code: @echo off set tempfile=bdw.txt del %tempfile% tasklist > %tempfile% type %tempfile% | find /i "firefox.exe" if errorlevel 0 if not errorlevel 1 goto IsRunning start firefox :exit del %tempfile% pause exit :IsRunning echo IsRunning goto exit
Here's the code: Code: Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load If (Process.GetProcessesByName("YourProccessNameWithout.EXE").Length >= 1) Then MessageBox.Show("Application already running in the system!", "MyApplication", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Environment.Exit(0) End If End Sub End Class