Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Executing Process from VB Application

Executing Process from VB Application

Scheduled Pinned Locked Moved Visual Basic
helpquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hsprasain
    wrote on last edited by
    #1

    Hi all: I want to execute .exe(process) when some events is fired from my application. I was able to execute my process by using my following code. Dim program As New Process program.StartInfo.FileName = "SH_EVP2.exe" program.Start() My Problem is I need to pass filename as paramters to .exe (process)when I execute it. can you advise me how shall I do this?

    C 1 Reply Last reply
    0
    • H hsprasain

      Hi all: I want to execute .exe(process) when some events is fired from my application. I was able to execute my process by using my following code. Dim program As New Process program.StartInfo.FileName = "SH_EVP2.exe" program.Start() My Problem is I need to pass filename as paramters to .exe (process)when I execute it. can you advise me how shall I do this?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Process.Start("SH_EVP2.exe " + yourParamString) will do it.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      H 1 Reply Last reply
      0
      • C Christian Graus

        Process.Start("SH_EVP2.exe " + yourParamString) will do it.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        H Offline
        H Offline
        hsprasain
        wrote on last edited by
        #3

        Hey: I did the exactly same that you have provided above. Unfortunately, I got some execptional handling error. Then, later I tried: Process.Start("SH_EVP2.exe ", "input1.sa") But still it is not taking input1.sa as a file parameter. Help please.

        P 1 Reply Last reply
        0
        • H hsprasain

          Hey: I did the exactly same that you have provided above. Unfortunately, I got some execptional handling error. Then, later I tried: Process.Start("SH_EVP2.exe ", "input1.sa") But still it is not taking input1.sa as a file parameter. Help please.

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          hsprasain wrote:

          Unfortunately, I got some execptional handling error.

          Christian's code should do the trick, what is the exception you were getting?


          "The clue train passed his station without stopping." - John Simmons / outlaw programmer

          H 1 Reply Last reply
          0
          • P Paul Conrad

            hsprasain wrote:

            Unfortunately, I got some execptional handling error.

            Christian's code should do the trick, what is the exception you were getting?


            "The clue train passed his station without stopping." - John Simmons / outlaw programmer

            H Offline
            H Offline
            hsprasain
            wrote on last edited by
            #5

            The exact code that I wrote as per Christian's suggestion is: Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString) The exception that I got while executing the application is: The system can't find the file specified. However I have input1.sa in the bin directory. I felt "SH_EVP2.exe" + yourParamString string got concanated and come up with new file name. Thus I'try the other one that I've posted above. Thanks for your help

            P C 3 Replies Last reply
            0
            • H hsprasain

              The exact code that I wrote as per Christian's suggestion is: Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString) The exception that I got while executing the application is: The system can't find the file specified. However I have input1.sa in the bin directory. I felt "SH_EVP2.exe" + yourParamString string got concanated and come up with new file name. Thus I'try the other one that I've posted above. Thanks for your help

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              You might have to specify the file path to the parameter file as well...


              "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

              H 1 Reply Last reply
              0
              • P Paul Conrad

                You might have to specify the file path to the parameter file as well...


                "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

                H Offline
                H Offline
                hsprasain
                wrote on last edited by
                #7

                By default it is taking taking the filpath of ../bin and my input file is inside bin. However, I tried with absolute path too. It doesn't make any differnce.

                1 Reply Last reply
                0
                • H hsprasain

                  The exact code that I wrote as per Christian's suggestion is: Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString) The exception that I got while executing the application is: The system can't find the file specified. However I have input1.sa in the bin directory. I felt "SH_EVP2.exe" + yourParamString string got concanated and come up with new file name. Thus I'try the other one that I've posted above. Thanks for your help

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #8

                  hsprasain wrote:

                  Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString)

                  You might be needing a space between the .exe and input1.sa By the looks of your code, it is looking for: SH_EVP2.exeinput1.sa Have you tried: Process.Start("SH_EVP2.exe " + yourParamString), note the space between the last 'e' in exe and the last double quote...


                  "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

                  H 1 Reply Last reply
                  0
                  • P Paul Conrad

                    hsprasain wrote:

                    Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString)

                    You might be needing a space between the .exe and input1.sa By the looks of your code, it is looking for: SH_EVP2.exeinput1.sa Have you tried: Process.Start("SH_EVP2.exe " + yourParamString), note the space between the last 'e' in exe and the last double quote...


                    "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

                    H Offline
                    H Offline
                    hsprasain
                    wrote on last edited by
                    #9

                    Hey: I tried as per your suggestions but it doesn't work out. Same error. I'm getting really frustrated.

                    1 Reply Last reply
                    0
                    • H hsprasain

                      The exact code that I wrote as per Christian's suggestion is: Dim yourParamString As String = "input1.sa" Process.Start("SH_EVP2.exe" + yourParamString) The exception that I got while executing the application is: The system can't find the file specified. However I have input1.sa in the bin directory. I felt "SH_EVP2.exe" + yourParamString string got concanated and come up with new file name. Thus I'try the other one that I've posted above. Thanks for your help

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      hsprasain wrote:

                      The system can't find the file specified.

                      Of course not, you're trying to start SH_EVP2.exeinput1.sa, which does not exist.

                      hsprasain wrote:

                      I felt "SH_EVP2.exe" + yourParamString string got concanated and come up with new file name.

                      Yeah, I thought it was obvious you needed a space.

                      hsprasain wrote:

                      However I have input1.sa in the bin directory.

                      Doesn't really matter. sh_evp2.exe needs to be in the same folder, or in the general lookup path for windows. Additionally, where-ever sh_evp2.exe is, *it* needs to be able to find input1.sa, that is, even if sh_Evp2.exe starts from anotehr folder, odds are very low it will be able to find input1.sa. Application.ExecutablePath ( from memory ) contains the path to your exe, use Path.Combine to create the full path to input1.sa, make sure that sh_evp2.exe is able to be found, put in a space, and it should work.

                      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups