Calling any Exe or Bat file by VB6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shashank Bhardwaj
    New Member
    • Feb 2008
    • 1

    Calling any Exe or Bat file by VB6.0

    Hello Friends!

    Can you help me for calling a exe or bat file by the code of vb6.0?

    Thanks.
  • VACEPROGRAMER
    Banned
    New Member
    • Nov 2007
    • 167

    #2
    I think Run("C:\ . .. . ") or Start("C:\..... ...") will help. In this moment I work on vb 2003 and vb 2005 so I need to see the code in vb6.0. I will send you the code, don't wary

    VxE

    Comment

    • VACEPROGRAMER
      Banned
      New Member
      • Nov 2007
      • 167

      #3
      Or maybe Open("C:\ . .. . .). never mynd , i need to see it . . .

      VxE

      Comment

      • gobblegob
        New Member
        • Dec 2007
        • 133

        #4
        Try this

        Code:
           Dim BatFile As String
           BatFile = "c:\first.bat"  
           ExecuteDOSCommand = Shell("""" & BatFile & """") > 0
        Gobble.

        Comment

        • lotus18
          Contributor
          • Nov 2007
          • 865

          #5
          Try this:

          [CODE=vb]Shell App.Path & "\sample.ex e", vbMaximizedFocu s[/CODE]

          Comment

          • lotus18
            Contributor
            • Nov 2007
            • 865

            #6
            Or :

            [CODE=vb]Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

            Call ShellExecute(Me .hwnd, vbNullString, App.Path & "\Sample.ex e", vbNullString, vbNullString, 2)[/CODE]

            Comment

            • VACEPROGRAMER
              Banned
              New Member
              • Nov 2007
              • 167

              #7
              Dim Q as String
              Dim Path as String
              DIm FullPath as String

              Q =""""
              Path = "C:\vace.ba t"
              FullPath = Q & Path & Q

              Shell(FullPath)

              VxE

              Comment

              • blueC

                #8
                Code:
                    Private Sub Button2_Click(ByVal sender As Object, _
                        ByVal e As System.EventArgs) Handles Button2.Click
                        Dim psi As New _
                            System.Diagnostics.ProcessStartInfo("C:\listfiles.bat")
                        psi.RedirectStandardOutput = True
                        psi.WindowStyle = ProcessWindowStyle.Hidden
                        psi.UseShellExecute = False
                        Dim listFiles As System.Diagnostics.Process
                        listFiles = System.Diagnostics.Process.Start(psi)
                        Dim myOutput As System.IO.StreamReader _
                            = listFiles.StandardOutput
                        listFiles.WaitForExit(2000)
                
                        If listFiles.HasExited Then
                            Dim output As String = myOutput.ReadToEnd
                            Debug.WriteLine(output)
                        End If
                    End Sub
                Last edited by MMcCarthy; Oct 18 '10, 08:05 PM. Reason: added code tags

                Comment

                Working...