How to close another application/program with c#, like eg, how to close Word with c# or how to RUN photoshop with c#
//it's not too complicated i think
Printable View
How to close another application/program with c#, like eg, how to close Word with c# or how to RUN photoshop with c#
//it's not too complicated i think
Process []pArry = Process.GetProcesses();
foreach(Process p in pArry)
{
string s = p.ProcessName;
s = s.ToLower();
if (s.CompareTo("winword") ==0)
{
p.Kill();
}
}
if u want to run photoshop with C# then
use
Process.Start("...");
where .. is the path of the exe.
-Paresh
Quote:
Originally posted by pareshgh
Process []pArry = Process.GetProcesses();
foreach(Process p in pArry)
{
string s = p.ProcessName;
s = s.ToLower();
if (s.CompareTo("winword") ==0)
{
p.Kill();
}
}
what if it's not word but other program???
well you can write what the program name is or pass from command line parameters or pass by reference to some objects.
-Paresh
can i use its path?
well yes actually, but you will need to cut it in order to get its process , as In my above sample "winword" is the process you are looking for.
Paresh
hmmmm how do i use path then? just put path in the winword place? and about the order, i don't quiet get it :S
what r u trying to do ?
-Paresh
first off, close a program with c#. but i wish i could put something like "C:\\program files\\microsoft office\\office 11\\winword.exe" instead of "winword"
second, shut down windows with c#?
and thanks so much for help! :)
hi,
you can close program with the same above code.Quote:
first off, close a program with c#.
check the Process class in more details. if FullName offers that and if it tells where it was loaded from then I think you will be able to do that.Quote:
but i wish i could put something like "C:\\program files\\microsoft office\\office 11\\winword.exe" instead of "winword"
Hmm That's nice. C# will close your application and windows then what will you work ! :D :D LOLQuote:
second, shut down windows with c#?
ok I will find and tell you. may be someone already knows can tell.
-Paresh
lol naw, i wanna write a program that will shut down my computer after say 60 mins so my computer will shut down after i go to sleep! :p
What should I do to these codes?Code:foreach(Process p in pArry)
{
string s = p.ProcessName;
s = s.ToLower();
if (s.CompareTo("wmplayer") ==0)
{
//Do nothing
}
else
{
MessageBox.Show("Windows Media Player is not running","",System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
Application.Exit();
break;
}
}
I want the MesageBox to show when windows media player is not running but it just keeps loopin even when wmp is running
and how can i control the volume in wmp with c#? someone said use directx but im not that good. can somebody explain how to do it?
thanks a lot! :)
anyone? :confused: