PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
How to know it's running?-VBForums
Results 1 to 12 of 12

Thread: How to know it's running?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Québec, Canada
    Posts
    284

    How to know it's running?

    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:
    1. isRunning = '...
    2. Do While isRunning
    3.   isRunning = '...
    4.   Sleep(500)
    5. Loop
    Last edited by blizarr; Jul 14th, 2006 at 02:36 PM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Québec, Canada
    Posts
    284

    Re: How to know it's running?

    Anyone???

  3. #3
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: How to know it's running?

    Yes, there is allot of code for this already on the Forums.

    Search for CreateToolhelp32Snapshot or EnumProcesses APIs. Or even "Running Process"(es)
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to know it's running?

    Here's a one-liner. Although it's pretty damn ugly:
    VB Code:
    1. Private Sub Form_Load()
    2.     Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE")
    3.     Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE")
    4. End Sub
    5.  
    6. Private Function IsProcessRunning(ByVal sPath As String) As Boolean
    7.     On Error Resume Next
    8.     IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count
    9. End Function

  5. #5
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: How to know it's running?

    hello bush.But it is showing flase value though the program is running
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1.  

  6. #6
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: How to know it's running?

    Remember i have windows 98 se. i think istead on win32 it will be some other thing.
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1.  

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to know it's running?

    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.

  8. #8
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: How to know it's running?

    VB Code:
    1. If App.PrevInstance = True Then
    2.         MsgBox "This Software Is Already Running", vbInformation + vbOKOnly, "Already Running"
    3. Else
    4.         MDIForm1.Show
    5. 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.

  9. #9
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: How to know it's running?

    Hi bush. the link is not working. please give correct link to download wmi. i will serach for wmi in google.
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1.  

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to know it's running?

    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.

  11. #11
    Member
    Join Date
    Jan 2007
    Posts
    51

    Re: How to know it's running?

    Quote Originally Posted by bushmobile
    Here's a one-liner. Although it's pretty damn ugly:
    VB Code:
    1. Private Sub Form_Load()
    2.     Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE")
    3.     Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE")
    4. End Sub
    5.  
    6. Private Function IsProcessRunning(ByVal sPath As String) As Boolean
    7.     On Error Resume Next
    8.     IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count
    9. End Function
    is there any other ways?

  12. #12
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to know it's running?

    Quote Originally Posted by Dark Byte
    is there any other ways?
    yup, here's a much better way: http://www.vbforums.com/showpost.php...82&postcount=2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width