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. C#
  4. Executing batch files in C#.

Executing batch files in C#.

Scheduled Pinned Locked Moved C#
tutorialcsharphelp
3 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.
  • J Offline
    J Offline
    James_722
    wrote on last edited by
    #1

    I won't go into details, but I would like to start a command line program from a c# form app. What I have been doing is write the file with c# code and execute it. I have been successful in changing the directory (cd ....) in the batch file. What i need now is to have another command called ("make"). I would like to know how to do this with either a batch file line or with something from a FCL class. To better illustrate my problem, here is an example of my programs batch output.

    set path=%path%;C:/pspdev/bin // these lines are static, they don't change
    set PSPSDK=C:/pspdev/psp/sdk
    cmd /k cd C:\pspdev\Projects\HomebewApp // this one changes directory on cmd startup, i tried to repeat the line with the "make" command but it didn't work.

    A R 2 Replies Last reply
    0
    • J James_722

      I won't go into details, but I would like to start a command line program from a c# form app. What I have been doing is write the file with c# code and execute it. I have been successful in changing the directory (cd ....) in the batch file. What i need now is to have another command called ("make"). I would like to know how to do this with either a batch file line or with something from a FCL class. To better illustrate my problem, here is an example of my programs batch output.

      set path=%path%;C:/pspdev/bin // these lines are static, they don't change
      set PSPSDK=C:/pspdev/psp/sdk
      cmd /k cd C:\pspdev\Projects\HomebewApp // this one changes directory on cmd startup, i tried to repeat the line with the "make" command but it didn't work.

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      If you want to do something in a batch (Sequence). Then write all those commands in batch file and execute it. If you want to start that batch file from a C# application. use Process.Start Ahsan Ullah Senior Software Engineer MCTS 2.0

      1 Reply Last reply
      0
      • J James_722

        I won't go into details, but I would like to start a command line program from a c# form app. What I have been doing is write the file with c# code and execute it. I have been successful in changing the directory (cd ....) in the batch file. What i need now is to have another command called ("make"). I would like to know how to do this with either a batch file line or with something from a FCL class. To better illustrate my problem, here is an example of my programs batch output.

        set path=%path%;C:/pspdev/bin // these lines are static, they don't change
        set PSPSDK=C:/pspdev/psp/sdk
        cmd /k cd C:\pspdev\Projects\HomebewApp // this one changes directory on cmd startup, i tried to repeat the line with the "make" command but it didn't work.

        R Offline
        R Offline
        realJSOP
        wrote on last edited by
        #3

        Well, you don't want to do the set commands every time you run the batch file because every time you do, it appends your path change to the system path. You should check the environment variables and make sure you need to do that before doing it. As far as the "cmd" line, you can set the working directory for an app by using the Process object.

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        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