execute more exe files in vb

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajeshs1708
    New Member
    • Oct 2011
    • 7

    execute more exe files in vb

    Want to run 5 exe files step by step using single push button in visual basic.......any one help??????????? ?
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    how do you want to define the intervals between the Exe's?
    All but with a time between each other or if the previous stops=> start the following one?

    Comment

    • rajeshs1708
      New Member
      • Oct 2011
      • 7

      #3
      sir,
      No specific time gap.I need by step by step.Tat is after one exe run completely,anot her exe should start run.. This is for software installtion program.I have 5 software exes.Instead of running each by manual,I need to run using single button vb scrpits.i.e when i click tat button 5 exes should run one by one..

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        This will start Notepad.
        After closing notepad it will start regedit.
        after closing it set a msgbox.

        Code:
        Option Explicit
        
        Private Function IsProcessRunning(ByVal processName As String) As Boolean
        Dim ObjP As Object
        Dim ObjP2 As Object
        Dim ObjW As Object
           Set ObjW = GetObject("winmgmts://.")
           Set ObjP = ObjW.execquery("Select * from win32_Process")
           For Each ObjP2 In ObjP
              If ObjP2.Name = processName Then
                 IsProcessRunning = True: Exit Function 'return true.
              End If
           Next
        End Function
        
        Private Sub Command1_Click()
           Shell "C:\WINDOWS\system32\notepad.exe", vbNormalFocus
           Do Until IsProcessRunning("notepad.exe") = False
           Loop
           Shell "C:\WINDOWS\regedit.exe", vbNormalFocus
           Do Until IsProcessRunning("regedit.exe") = False
           Loop
           MsgBox "done"
        End Sub

        Comment

        • rajeshs1708
          New Member
          • Oct 2011
          • 7

          #5
          thanks..Guido for your valuable reply.. I will confirm u once i incorpated

          Comment

          • rajeshs1708
            New Member
            • Oct 2011
            • 7

            #6
            Reg vb query

            Dear guido,


            I checked the program .. its working fine for our application.I need small change in that.i dont want to install the exe if already installed.That is suppose am installing 5 exe using the scripts,if the 4th exe get faled to install due to some reasons(like hardware problem,power off),in that case if i again execute the scripts,i dont want to execute the first 3 exe which is properly installed.the program have to install 4 th automatically.i n other terms i need to check the properly installed exe in the program.. Kindly help me to include this..

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              Just write in a text file (Log) which files are installed.
              Read this file at startup and check during installation if the programs are present in the Log text.
              Attached Files

              Comment

              • rajeshs1708
                New Member
                • Oct 2011
                • 7

                #8
                sir,

                Explanation not clear..can u please explain briefly.i.e where i need to incorpate the scrpits that u send on zip file

                Comment

                • Guido Geurs
                  Recognized Expert Contributor
                  • Oct 2009
                  • 767

                  #9
                  Save each time a program has been installed in a Log (.txt) file with:
                  Code:
                  Dim FNumOut As Integer
                     FNumOut = FreeFile()
                     On Error GoTo Error_Log
                     Open App.Path & "\program.log" For Output As #FNumOut
                        If InStr...
                  ...
                        Write #FNumOut, "notepad.exe"
                        If InStr...
                  ...
                        Write #FNumOut, "regedit.exe"
                     Close #FNumOut
                  ...
                  Exit Sub
                  Error_Log:
                     MsgBox "there is an error in writing Log file"
                     Close #FNumOut
                  Load the Log file at startup with:
                  Code:
                  Private Sub Form_Load()
                  Dim FNumIn As Integer
                  Dim INPUT_TEXT As String
                     If Dir$(App.Path & "\program.log") <> "program.log" Then _
                        GoTo No_Log
                     FNumIn = FreeFile()
                     On Error GoTo Error_Log_File
                     Open App.Path & "\program.log" For Input As #FNumIn
                     Do While Not EOF(FNumIn)
                        Line Input #FNumIn, INPUT_TEXT
                        LOGPRGS = LOGPRGS & INPUT_TEXT
                     Loop
                     Close #FNumIn
                  Exit Sub
                  No_Log:
                     MsgBox ("There is no ...\program.log file ")
                  Exit Sub
                  Error_Log_File:
                     MsgBox ("There is an error in the ...\program.log file ")
                  End Sub
                  Check if the program has been installed with:
                  Code:
                  ...
                        If InStr(LOGPRGS, "notepad.exe") = 0 Then
                           Shell "C:\WINDOWS....
                  ....

                  Comment

                  • rajeshs1708
                    New Member
                    • Oct 2011
                    • 7

                    #10
                    Dear guido,


                    I need to run that vb project as a exe so that i run that on other pc that donot have vb...Can u help to convet that as exe

                    Comment

                    • Guido Geurs
                      Recognized Expert Contributor
                      • Oct 2009
                      • 767

                      #11
                      Select in Menu : File - Make Exe (see GIF attached)
                      Attached Files

                      Comment

                      Working...