execute and close application in vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • woyzer
    New Member
    • Mar 2013
    • 3

    execute and close application in vb6

    how to run / execute other application and close it automatically after 5 minutes in visual basic 6 ?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    A quick search should find you the details on how to execute - it's a question which has been answered here a number of times.

    As for the 5 minutes, I'd suggest you use something like the DateAdd function to add 5 minutes to the current time, then sit in a Do loop executing DoEvents until the time passes that value. Alternatively, you could set a Timer control to trigger your code. However, I think the maximum interval they can wait for is about a minute or something (possibly half a minute?) so you'd need to trigger a few times to reach 5 minutes.

    Comment

    • woyzer
      New Member
      • Mar 2013
      • 3

      #3
      hi Killer42, thanks for answer.

      I have successfull make a program to run a application and close it after 5 minutes and reopen it again after 3 seconds closed.

      i used this codes to open a application :

      Code:
      app = Shell(Environ$("programFiles") + "\Internet Explorer\iexplore.exe", vbNormalFocus)
      and i use this procedure to close / terminate the application :

      Code:
      Private Sub TerminateProcess(app_exe As String)
          Dim Process As Object
          For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = '" & app_exe & "'")
              Process.Terminate
          Next
      End Sub
      Now i want to open firefox with a URL opened in a tab, i want to close that tab without closing firefox, anybody can help?
      Last edited by Rabbit; Apr 7 '13, 05:43 AM. Reason: Please use code tags when posting code.

      Comment

      • woyzer
        New Member
        • Mar 2013
        • 3

        #4
        i use 1 minute timer interval and use a public variable (dim mnt as byte) that sub with 1 every 1 minute, count it until reach 5, set as 0 again after reach 5 and close a application opened before

        Comment

        Working...