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 an exe with C# code

Executing an exe with C# code

Scheduled Pinned Locked Moved C#
questioncsharpdebugginghelp
9 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.
  • M Offline
    M Offline
    MatthysDT
    wrote on last edited by
    #1

    I am attempting to write some code that will execute one of my EXE's from another project. This other EXE file uses an INI file which is located in the same folder as the exe itself. But when I run the exe file using C# code, the exe creates a new default INI file here: C:\Documents and Settings\UserName\Local Settings\Application Data\Temporary Projects\KeepAlive\bin\Debug (this is the projects directory) How do I execute an exe in code asif it was simply a shorcut being double-clicked on the desktop? I have tried the following:

    Process.Start(@ApplicationFullPath);

    string str = (@ApplicationFullPath;
    Process process = new Process();
    process.StartInfo.FileName = str;
    process.Start

    Both of these solution had the same problem.

    M 1 Reply Last reply
    0
    • M MatthysDT

      I am attempting to write some code that will execute one of my EXE's from another project. This other EXE file uses an INI file which is located in the same folder as the exe itself. But when I run the exe file using C# code, the exe creates a new default INI file here: C:\Documents and Settings\UserName\Local Settings\Application Data\Temporary Projects\KeepAlive\bin\Debug (this is the projects directory) How do I execute an exe in code asif it was simply a shorcut being double-clicked on the desktop? I have tried the following:

      Process.Start(@ApplicationFullPath);

      string str = (@ApplicationFullPath;
      Process process = new Process();
      process.StartInfo.FileName = str;
      process.Start

      Both of these solution had the same problem.

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      and what is the path of the .exe you want to execute?

      M 1 Reply Last reply
      0
      • M musefan

        and what is the path of the .exe you want to execute?

        M Offline
        M Offline
        MatthysDT
        wrote on last edited by
        #3

        "C:\Program Files\Company\ApplicationPath"

        Doggy treat[^]

        M 1 Reply Last reply
        0
        • M MatthysDT

          "C:\Program Files\Company\ApplicationPath"

          Doggy treat[^]

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          so just to clarify. you have an apllication in C:\..\Application that you want to launch an applciation in C:\..\keepAlive\Bin\Debug. The application in debug is supposed to create an INI file in its location but instead it creates it in the location of the application that is loading it? (LOL maybe not so clear)

          M 1 Reply Last reply
          0
          • M musefan

            so just to clarify. you have an apllication in C:\..\Application that you want to launch an applciation in C:\..\keepAlive\Bin\Debug. The application in debug is supposed to create an INI file in its location but instead it creates it in the location of the application that is loading it? (LOL maybe not so clear)

            M Offline
            M Offline
            MatthysDT
            wrote on last edited by
            #5

            Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.

            Doggy treat[^]

            A M 2 Replies Last reply
            0
            • M MatthysDT

              Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.

              Doggy treat[^]

              A Offline
              A Offline
              Ankit Rajpoot
              wrote on last edited by
              #6

              Thats because when B starts A, A's startup path is set to B's home directory. Use the following algorithm in B to start A: 1. Change the directory where A resides. 2. Start A This should solve your problem.

              Excuse me for buttin' in, but I'm interrupt driven.

              M 1 Reply Last reply
              0
              • M MatthysDT

                Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.

                Doggy treat[^]

                M Offline
                M Offline
                musefan
                wrote on last edited by
                #7

                i assume app A uses applicationStartupPath to find where to put the INI, which when started from App B becomes the startup path of App B instead of where it was executed from. You could try passing a parameter to application A that tells it its startup path, but you would need to Modify App A to handle the parameter. Something like a global variable with the startupPath, then if paramter is present set it to the passed paramter otherwise use the Application.StartupPath when no paramter is passed

                M 1 Reply Last reply
                0
                • A Ankit Rajpoot

                  Thats because when B starts A, A's startup path is set to B's home directory. Use the following algorithm in B to start A: 1. Change the directory where A resides. 2. Start A This should solve your problem.

                  Excuse me for buttin' in, but I'm interrupt driven.

                  M Offline
                  M Offline
                  MatthysDT
                  wrote on last edited by
                  #8

                  How do I change the Directory where A resides? A is perfect where it is, I'm not sure what you mean...

                  Doggy treat[^]

                  1 Reply Last reply
                  0
                  • M musefan

                    i assume app A uses applicationStartupPath to find where to put the INI, which when started from App B becomes the startup path of App B instead of where it was executed from. You could try passing a parameter to application A that tells it its startup path, but you would need to Modify App A to handle the parameter. Something like a global variable with the startupPath, then if paramter is present set it to the passed paramter otherwise use the Application.StartupPath when no paramter is passed

                    M Offline
                    M Offline
                    MatthysDT
                    wrote on last edited by
                    #9

                    That I can do! Thanx!

                    Doggy treat[^]

                    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