I am trying to run MS dos call command from a C# form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce Hutton
    New Member
    • Aug 2010
    • 6

    I am trying to run MS dos call command from a C# form.

    The call command runs a program called m4dc.cmd

    The actual code is.
    call c:muller\mucam\ cam_cli\m4dc.cm d C:\MULLER\MUCAM \conver\%1.ep

    How can I run this call cammand in a C# form application?

    The call comand calls the m4dc.cmd program and I think points to the address C:\MULLER|MUCAM |convert\%1.ep
    and waits until the the new upt file has been created
    It takes the ep file stored at the above location and converts the ep file to a upt file.
    I hope you can help with this.
    Thanks
    Bruce
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #2
    DOS or the console?

    Comment

    • Bruce Hutton
      New Member
      • Aug 2010
      • 6

      #3
      Dos
      The C# program has to run the MS DOS call commad

      Comment

      • Aimee Bailey
        Recognized Expert New Member
        • Apr 2010
        • 197

        #4
        how about this?:

        Code:
        Process.Start("call c:muller\mucam\cam_cli\m4dc.cmd C:\MULLER\MUCAM\conver\%1.ep");

        Comment

        • Bruce Hutton
          New Member
          • Aug 2010
          • 6

          #5
          Thanks Aimee
          I tried this first of all but it didn't work. I think the problem is with the call parameter C:\Muller\MUCAM \convert\%1.ep.
          I think it also need to use \\ between the directories. eg
          C:\\Muller\\MUC AM\\convert\\%1 .ep
          My code is

          System.Diagnost ics.Process.Sta rt("call C:\\muller\\muc am\\cam_cli\\m4 dc.cmd C:\\MULLER\\MUC AM\\convert\\%1 .ep");
          Do you know if Process.Start will work with the call paramenter?

          Thanks very much for your help

          Comment

          • Aimee Bailey
            Recognized Expert New Member
            • Apr 2010
            • 197

            #6
            you could try...

            Code:
            System.Diagnostics.Process.Start("call \"C:\\muller\\mucam\\cam_cli\\m4dc.cmd\" \"C:\\MULLER\\MUCAM\\convert\\%1.ep\"");
            that's using escape params.

            Comment

            • GaryTexmo
              Recognized Expert Top Contributor
              • Jul 2009
              • 1501

              #7
              How do you get the value for that %1? My only knowledge of that syntax is when making batch files, the %1 (%2, %3, ...) are the parameters to a batch file. Your program would get that parameter in a different way, wouldn't it?

              Unless there's something else I don't know about (quite likely, I admit), you'll need to insert the parameter into your string...

              Code:
              public void PerformCall(string param)
              {
                string callText = string.Format(
                  "call \"C:\\muller\\mucam\\cam_cli\\m4dc.cmd\" \"C:\\MULLER\\MUCAM\\convert\\{0}.ep\"",
                  param);
              
                System.Diagnostics.Process.Start(callText);
              }
              Is that what you were looking for, or am I way out to lunch?

              Comment

              • Aimee Bailey
                Recognized Expert New Member
                • Apr 2010
                • 197

                #8
                I think gary is on the money :)

                Comment

                • Bruce Hutton
                  New Member
                  • Aug 2010
                  • 6

                  #9
                  Thanks Aimee and Gary
                  Sorry I didn't get back to you but the time difference in Aust is a problem.
                  I will try both of your suggestions but I have to send the code to the UK to try. I tied similar code to Gary's using StartIfno but didn't work. I will give both yours suggestions ago and get back to you.

                  Thanks very much for your help. I can write a batch file with the MS Dos call function in it and stat that with Process.Start() ; and I am sure that will work. But I would like to have the complete code in C#.NET if I could. I have programed in C, C++ C++.NET and C# for over 20 years this is just tricking me.

                  Regards
                  Bruce

                  Comment

                  • Bruce Hutton
                    New Member
                    • Aug 2010
                    • 6

                    #10
                    Sorry Gary
                    I didn't answer question on %1. This is a EP file my code produces and stores it in C:\MULLER|MUCAM |convert\
                    The actual call MSDOs function is part of another batch file that works OK but it just run as a batch file. The problem is to get the call function to work from a C# Form appliction.

                    Regards
                    Bruce

                    Comment

                    Working...