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. how to can i run or execute another program from C# ... like winword for example ??

how to can i run or execute another program from C# ... like winword for example ??

Scheduled Pinned Locked Moved C#
tutorialcsharpquestion
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.
  • Z Offline
    Z Offline
    Zero coder
    wrote on last edited by
    #1

    hello i have been looking for this code for a long time its about how to execute a program like excel or word or any .exe file from c# for example i want to make a button that runs winword when its pressed and thx :confused::confused:

    C E 2 Replies Last reply
    0
    • Z Zero coder

      hello i have been looking for this code for a long time its about how to execute a program like excel or word or any .exe file from c# for example i want to make a button that runs winword when its pressed and thx :confused::confused:

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

      Process.Start, but you need the path to Word, OR you can pass in the path to a word doc, and if Word is present, it will open. If not, it will throw an exception.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • Z Zero coder

        hello i have been looking for this code for a long time its about how to execute a program like excel or word or any .exe file from c# for example i want to make a button that runs winword when its pressed and thx :confused::confused:

        E Offline
        E Offline
        erfi
        wrote on last edited by
        #3

        here is a simple application I wrote : there is a combobox on my form which lets user to select a program. in this case i just added 3 programs to it : (mediaplayer, freecell, MinesWeeper) also you can add the command line arguments to your process. by clicking the run button the fallowing code will run.

        private void runbtn_Click(object sender, System.EventArgs e)
        {
        Process myProcess = new Process();
        int selectedIndex = comboBox1.SelectedIndex;

            switch (selectedIndex)
            {
                case 0:
                    myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
                    //myProcess.StartInfo.Arguments = "g:\\\\path\\\\filename.mp3";                
                    break;
                case 1:
                    myProcess.StartInfo.FileName = "c:/windows/system32/winmine.exe";
                    break;
                case 2:
                    myProcess.StartInfo.FileName = "c:/windows/system32/freecell.exe";
                    break;
                default:
                    myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
                    break;
            }
        myProcess.Start();
        

        }

        sometimes 0 can be 1

        modified on Sunday, June 15, 2008 10:26 AM

        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