Is there a way to know if a specific exe is currently running and (of course) to know if it's not running?
Something like
VB Code:
isRunning = '... Do While isRunning isRunning = '... Sleep(500) Loop
Printable View
Is there a way to know if a specific exe is currently running and (of course) to know if it's not running?
Something like
VB Code:
isRunning = '... Do While isRunning isRunning = '... Sleep(500) Loop
Anyone???
Yes, there is allot of code for this already on the Forums.
Search for CreateToolhelp32Snapshot or EnumProcesses APIs. Or even "Running Process"(es)
Here's a one-liner. Although it's pretty damn ugly:VB Code:
Private Sub Form_Load() Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE") Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE") End Sub Private Function IsProcessRunning(ByVal sPath As String) As Boolean On Error Resume Next IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count End Function
hello bush.But it is showing flase value though the program is running
Remember i have windows 98 se. i think istead on win32 it will be some other thing.
remove the On Error Resume Next and see what you get.
WMI does not come preinstalled on 98, so you may have to install it yourself.
VB Code:
If App.PrevInstance = True Then MsgBox "This Software Is Already Running", vbInformation + vbOKOnly, "Already Running" Else MDIForm1.Show End If
You can use this property in a Load event procedure to specify whether a user is already running an instance of an application. Depending on the application, you might want only one instance running in the Microsoft Windows operating environment at a time.
Note Since a computer running Windows NT can support multiple desktops, if you use a component designed to work with distributed COM, it can result in the following scenario:
A client program in a user desktop requests one of the objects the component provides. Because the component is physically located on the same machine, the component is started in the user desktop.
Subsequently, a client program on another computer uses distributed COM to request one of the objects the component provides. A second instance of the component is started, in a system desktop.
There are now two instances of the component running on the same NT computer, in different desktops.
This scenario is not a problem unless the author of the component has placed a test for App.PrevInstance in the startup code for the component to prevent multiple copies of the component from running on the same computer. In this case, the remote component creation will fail. :thumb:
Hi bush. the link is not working. please give correct link to download wmi. i will serach for wmi in google.
vivek: the link wasn't to a download, it was to the WMI documentation - i suggest you have a read up and make an informed decision rather than downloading and installing something without knowing what it is.
is there any other ways?Quote:
Originally Posted by bushmobile
yup, here's a much better way: http://www.vbforums.com/showpost.php...82&postcount=2Quote:
Originally Posted by Dark Byte