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