I think the only option would be iterating through list of running processes and then killing them by name. I don't think there's a way to kill any browser without knowing it's process name. Listing of processes can be done with the following example code:
Easiest option would be installing browsers on your computer and checking process names. If you don't want to do that try to find process names in Google, all major ones should be there somewhere.
Im just wandering if there's a code in c# that we can use
to close all kinds of web browser whether if its IE, Firefox, or
Google Chrome? I need a code that is capable of closing a web browser. Thank you.
Please clarify your requirement.
is this something that you wish to do on yourserver or on the
end users' computers ... if it's the latter, assuming that you mean actually closing their browser, AFAIK, you can
not close your end users' browsers.
What is the goal that you are trying to achieve, and why are you trying to achieve that
goal?
Please explain in order that forums.asp.net members might have enough information to help you.
thnx/g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
timmack
Member
26 Points
74 Posts
using c# to exit or close a browser?
Dec 13, 2011 01:02 PM|LINK
Hello!
Im just wandering if there's a code in c# that we can use to close all kinds of web browser whether if its IE, Firefox, or
Google Chrome? I need a code that is capable of closing a web browser. Thank you.
vytautas.ziu...
Contributor
3854 Points
691 Posts
Re: using c# to exit or close a browser?
Dec 13, 2011 01:07 PM|LINK
I think the only option would be iterating through list of running processes and then killing them by name. I don't think there's a way to kill any browser without knowing it's process name. Listing of processes can be done with the following example code:
http://www.howtogeek.com/howto/programming/get-a-list-of-running-processes-in-c/
timmack
Member
26 Points
74 Posts
Re: using c# to exit or close a browser?
Dec 13, 2011 01:27 PM|LINK
Thanks vytautas,
Is this applicable to all types of browsers? How do I determine the process name of a certain browser that is running?
vytautas.ziu...
Contributor
3854 Points
691 Posts
Re: using c# to exit or close a browser?
Dec 13, 2011 01:37 PM|LINK
Easiest option would be installing browsers on your computer and checking process names. If you don't want to do that try to find process names in Google, all major ones should be there somewhere.
timmack
Member
26 Points
74 Posts
Re: using c# to exit or close a browser?
Dec 13, 2011 02:18 PM|LINK
Thanks I'll try that hope this works for me.
vinnypatel14
Participant
796 Points
125 Posts
Re: using c# to exit or close a browser?
Dec 14, 2011 06:30 AM|LINK
Hello,
May be this link will work for you...
http://weblogs.asp.net/stanleygu/archive/2010/03/31/tip-13-kill-a-process-from-local-to-remote.aspx
Live The Life mAh OwN wAy !!
Vinny..
mageshsoftte...
Member
563 Points
142 Posts
Re: using c# to exit or close a browser?
Dec 14, 2011 06:45 AM|LINK
hi hope this link help for u...
http://forums.asp.net/t/1203440.aspx/1/10
thanks
MAGESHBABU K
Regards
Magesh.
Senior Software Developer.
gerrylowry
All-Star
20577 Points
5721 Posts
Re: using c# to exit or close a browser?
Dec 15, 2011 01:03 PM|LINK
@ timmack
Please clarify your requirement.
is this something that you wish to do on your server or on the end users' computers ... if it's the latter, assuming that you mean actually closing their browser, AFAIK, you can not close your end users' browsers.
What is the goal that you are trying to achieve, and why are you trying to achieve that goal?
Please explain in order that forums.asp.net members might have enough information to help you.
thnx/g.
fundu.ujjwal
Member
365 Points
102 Posts
Re: using c# to exit or close a browser?
Dec 15, 2011 10:21 PM|LINK
Process[] processNames = Process.GetProcessesByName("iexplore"); foreach (Process item in processNames) { item.Kill(); } Process[] processNames = Process.GetProcessesByName("firefox"); foreach (Process item in processNames) { item.Kill(); } Process[] processNames = Process.GetProcessesByName("chrome"); foreach (Process item in processNames) { item.Kill(); }Ujjwal ;)
More I learn I know, how less I know..
abdheshtech
Member
99 Points
32 Posts
Re: using c# to exit or close a browser?
May 01, 2013 07:43 AM|LINK
i have write that code it's running on local system but when we have live i getting exception
Thanks in advance
Web Developer