Passing an option to an EXE from an EXE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Takuya Matsumoto

    Passing an option to an EXE from an EXE

    Greetings to all,

    I really appreciate the support from this community and I've made some
    advancements, but again I'm hitting a wall...

    I'm trying to write a program in C# that passes an option to another EXE so
    that the second program knows what to do.
    I belive the syntax is like below, but the problem arises when I add the
    option; it does not find the exe file.

    System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
    /option:"doSomet hing");

    As a test, I tried "Run" option of Windows as below:
    "c:\program files\program\s ample.exe" /option:"doSomet hing"
    and this works fine.

    I'm puzzled as to what the problem is.
    What am I doing wrong?

    Thanks very much for your help!

    Cheers,

    Takuya

  • Michael A. Covington

    #2
    Re: Passing an option to an EXE from an EXE

    Remember the syntax of strings in C#. I think you want to type this:

    System.Diagnost ics.Process.Sta rt(
    "\"c:\\Prog ram FIles\\Program\ \Sample.exe\" /option:\"doSome thing\"");

    That is, put \ before every \ or " that occurs within a string.


    "Takuya Matsumoto" <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp> wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=blue]
    > Greetings to all,
    >
    > I really appreciate the support from this community and I've made some
    > advancements, but again I'm hitting a wall...
    >
    > I'm trying to write a program in C# that passes an option to another EXE so
    > that the second program knows what to do.
    > I belive the syntax is like below, but the problem arises when I add the
    > option; it does not find the exe file.
    >
    > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
    > /option:"doSomet hing");
    >
    > As a test, I tried "Run" option of Windows as below:
    > "c:\program files\program\s ample.exe" /option:"doSomet hing"
    > and this works fine.
    >
    > I'm puzzled as to what the problem is.
    > What am I doing wrong?
    >
    > Thanks very much for your help!
    >
    > Cheers,
    >
    > Takuya
    >[/color]

    Comment

    • Takuya Matsumoto

      #3
      Re: Passing an option to an EXE from an EXE

      > Remember the syntax of strings in C#. I think you want to type this:[color=blue]
      >
      > System.Diagnost ics.Process.Sta rt(
      > "\"c:\\Prog ram FIles\\Program\ \Sample.exe\" /option:\"doSome thing\"");
      >
      > That is, put \ before every \ or " that occurs within a string.[/color]


      Woops, my typing mistake.
      I had actually done so.

      Cheers,

      Takuya





      Comment

      • Ryan LaNeve

        #4
        Re: Passing an option to an EXE from an EXE

        <irrelevant newsgroups removed>
        "Takuya Matsumoto" <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp>
        wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=blue]
        > Greetings to all,
        >
        > <snipped>
        >
        > I'm trying to write a program in C# that passes an option to another EXE[/color]
        so[color=blue]
        > that the second program knows what to do.
        > I belive the syntax is like below, but the problem arises when I add the
        > option; it does not find the exe file.
        >
        > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
        > /option:"doSomet hing");
        >
        > <snipped>
        >
        > Cheers,
        >
        > Takuya[/color]

        The Process class' "Start" method has an override specifically for supplying
        arguments to the executable being started. In your case, the syntax would
        be:
        System.Diagnost ics.Process.Sta rt("C:\\Progra m Files\\Program\ \Sample.exe",
        "/option:\"doSome thing\"");

        Good luck.
        --
        Ryan LaNeve, MCSD.NET



        Comment

        • Romain TAILLANDIER

          #5
          Re: Passing an option to an EXE from an EXE

          hi,

          i think you can also put an @ before your string, then the echap char would
          be automatic.
          @"c:\program files\program\s ample.exe" would work i suppose.

          ROM



          "Michael A. Covington" <look@www.covin gtoninnovations .com.for.addres s> a
          ecrit dans le message de news: #XUSq$3lDHA.201 2@TK2MSFTNGP12. phx.gbl...
          Remember the syntax of strings in C#. I think you want to type this:

          System.Diagnost ics.Process.Sta rt(
          "\"c:\\Prog ram FIles\\Program\ \Sample.exe\" /option:\"doSome thing\"");

          That is, put \ before every \ or " that occurs within a string.


          "Takuya Matsumoto" <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp>
          wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=blue]
          > Greetings to all,
          >
          > I really appreciate the support from this community and I've made some
          > advancements, but again I'm hitting a wall...
          >
          > I'm trying to write a program in C# that passes an option to another EXE[/color]
          so[color=blue]
          > that the second program knows what to do.
          > I belive the syntax is like below, but the problem arises when I add the
          > option; it does not find the exe file.
          >
          > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
          > /option:"doSomet hing");
          >
          > As a test, I tried "Run" option of Windows as below:
          > "c:\program files\program\s ample.exe" /option:"doSomet hing"
          > and this works fine.
          >
          > I'm puzzled as to what the problem is.
          > What am I doing wrong?
          >
          > Thanks very much for your help!
          >
          > Cheers,
          >
          > Takuya
          >[/color]


          Comment

          • Phil Swartzell

            #6
            Re: Passing an option to an EXE from an EXE

            I don't have it in front of me, but I was pretty sure that there is an
            overload for process.start that allows you to pass a command line argument.
            It's not all passed as one string. The overloads second parameter is an
            object array if I remember correctly.

            Phil

            "Takuya Matsumoto" <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp>
            wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=blue]
            > Greetings to all,
            >
            > I really appreciate the support from this community and I've made some
            > advancements, but again I'm hitting a wall...
            >
            > I'm trying to write a program in C# that passes an option to another EXE[/color]
            so[color=blue]
            > that the second program knows what to do.
            > I belive the syntax is like below, but the problem arises when I add the
            > option; it does not find the exe file.
            >
            > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
            > /option:"doSomet hing");
            >
            > As a test, I tried "Run" option of Windows as below:
            > "c:\program files\program\s ample.exe" /option:"doSomet hing"
            > and this works fine.
            >
            > I'm puzzled as to what the problem is.
            > What am I doing wrong?
            >
            > Thanks very much for your help!
            >
            > Cheers,
            >
            > Takuya
            >[/color]


            Comment

            • Takuya Matsumoto

              #7
              Re: Passing an option to an EXE from an EXE

              Yes, Phil!
              It worked perfectly.
              Thanks very much for your help!
              Cheers,
              Takuya


              "Phil Swartzell" <pswartzell1@co mcast.net> wrote in message
              news:%23BoPGh9l DHA.2444@TK2MSF TNGP09.phx.gbl. ..[color=blue]
              > I don't have it in front of me, but I was pretty sure that there is an
              > overload for process.start that allows you to pass a command line[/color]
              argument.[color=blue]
              > It's not all passed as one string. The overloads second parameter is an
              > object array if I remember correctly.
              >
              > Phil
              >
              > "Takuya Matsumoto"[/color]
              <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp>[color=blue]
              > wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=green]
              > > Greetings to all,
              > >
              > > I really appreciate the support from this community and I've made some
              > > advancements, but again I'm hitting a wall...
              > >
              > > I'm trying to write a program in C# that passes an option to another EXE[/color]
              > so[color=green]
              > > that the second program knows what to do.
              > > I belive the syntax is like below, but the problem arises when I add the
              > > option; it does not find the exe file.
              > >
              > > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
              > > /option:"doSomet hing");
              > >
              > > As a test, I tried "Run" option of Windows as below:
              > > "c:\program files\program\s ample.exe" /option:"doSomet hing"
              > > and this works fine.
              > >
              > > I'm puzzled as to what the problem is.
              > > What am I doing wrong?
              > >
              > > Thanks very much for your help!
              > >
              > > Cheers,
              > >
              > > Takuya
              > >[/color]
              >
              >[/color]

              Comment

              • Takuya Matsumoto

                #8
                Re: Passing an option to an EXE from an EXE

                Thanks Ryan,

                It worked great the way you specified it.
                Cheers,

                Takuya


                "Ryan LaNeve" <ryan@nolaneves pam.com> wrote in message
                news:uvIIA34lDH A.2244@TK2MSFTN GP12.phx.gbl...[color=blue]
                > <irrelevant newsgroups removed>
                > "Takuya Matsumoto"[/color]
                <adminCAPS_FOR_ SPAM_AND_VIRUS_ PROTECTION@saka ecorp.co.jp>[color=blue]
                > wrote in message news:%23c%23v54 3lDHA.3688@TK2M SFTNGP11.phx.gb l...[color=green]
                > > Greetings to all,
                > >
                > > <snipped>
                > >
                > > I'm trying to write a program in C# that passes an option to another EXE[/color]
                > so[color=green]
                > > that the second program knows what to do.
                > > I belive the syntax is like below, but the problem arises when I add the
                > > option; it does not find the exe file.
                > >
                > > System.Diagnost ics.Process.Sta rt("c:\program files\program\s ample.exe"
                > > /option:"doSomet hing");
                > >
                > > <snipped>
                > >
                > > Cheers,
                > >
                > > Takuya[/color]
                >
                > The Process class' "Start" method has an override specifically for[/color]
                supplying[color=blue]
                > arguments to the executable being started. In your case, the syntax would
                > be:
                > System.Diagnost ics.Process.Sta rt("C:\\Progra m Files\\Program\ \Sample.exe",
                > "/option:\"doSome thing\"");
                >
                > Good luck.
                > --
                > Ryan LaNeve, MCSD.NET
                > http://weblogs.asp.net/rlaneve
                >
                >[/color]

                Comment

                Working...