Solved

Remove IE9 using WMI

Posted on 2012-03-28
11
697 Views
Last Modified: 2012-05-03
Hello Experts,

I would like to know if it's possible to write code using WMI and somehow tie that to a link on a web page for a user to click on in order to run the WMI code. The reason I ask is because I support 500+ employees and we use a web app that is only compatible with IE8 and lately IE9 has been included in Windows Update. So rather than get flodded with calls I was wondering if it could be handled by having the user navigate to a page and click on a link to execute the code. I have never written code using WMI but from what I have read this is what I should be using.

Requirments:
  - User clicks on link from internal website.
  - Code needs to check to first see if IE9 is installed. If so, continue to remove if not, display message that IE9 is not installed.

Also, users have Windows XP, 7x32 and 7x64 installed. I don't believe IE9 works with XP so I should only need the code to work with 7x32 and 7x64.

I'm using ASP.NET 4.0 and C#.

Thanks in advance!
0
Comment
Question by:asp_net2
  • 6
  • 5
11 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37780654
after some reading on the net this solution is the common one to uninstall ie9 and rollback to ie8.
http://www.kolltveit.org/?p=514

to run the batch from .Net with admin rights, use the following code:
try

{

ProcessStartInfo procInfo = new ProcessStartInfo();

procInfo.UseShellExecute = true;

procInfo.FileName = @"CMD.bat";  //The file in that DIR.

procInfo.WorkingDirectory = @""; //The working DIR.

procInfo.Verb = "runas";

Process.Start(procInfo);  //Start that process.

}

catch (Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}           

Open in new window


copied from http://social.msdn.microsoft.com/Forums/en/windowssecurity/thread/06a11012-1ce2-46ea-a47f-945b23e27f89
0
 
LVL 4

Author Comment

by:asp_net2
ID: 37781624
Hi sedgwick,

Ok, thank you.

Should I wrap the code above into the ButtonClick Event?

Also, I don't fully understand the .bat file would you be able to copy/paste that for me into a .txt file and then I can rename it myself?

Where do I store the .bat file at on my end and how do I reference that in the code?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37781922
I'm sorry i didn't fully understand your requirements till now.

since u want to uninstall ie9 from the client machine u can't really use this code (it's server side).
as a whole, accessing local machine from client is a security breach even if it's trusted zone and so on (scripts run in a sandbox in which they can only perform web-related actions).
u can download some plugins which requires to dropping most of the browser security and even so they are not reliable.

so basically it's impossible and for a good reason.
you can write an IE ActiveX control to do that but i wouldn't recommend this approach.

what you should do is notify users that IE9 is not supported and let them download a batch/script which downgrade their browser to IE8.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37781939
the alternative is to use xcopy to copy batch file to all end-users machines and run it to downgrade the IE version.
you can use powershell to copy the script to a network share and run it from there as well.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 37781966
Hi sedgwick,

Ok. Is it still possible to use the .bat file from the link that you sent me and then I can post the .bat file into a .zip folder and then the client can download and extract the .bat file and run it from their local computer?

If so, can you help me with the .bat file from the link you sent me? This way we are not running it from the browser but instead downloading it into a .zip file.

Thanks in advance!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 42

Expert Comment

by:sedgwick
ID: 37782103
yes u can use the batch.
but u need to instruct them to run it as admin, Right click the file -> Run as Administrator
0
 
LVL 4

Author Comment

by:asp_net2
ID: 37783006
Hi sedgwick,

would you be able to upload that .bat file and upload it to me in a .txt file? So I make sure I dont screw it up.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 37783369
Hi sedgwick,

Ok, so I visited the site that you supplied and put the following code below into Notepad and then saved the file as ie9.bat. When I run the .bat file a cmd windows appears for 1 second then disappers but nothing happens after that.


FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*9.*.mum /c “cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname”
0
 
LVL 4

Author Comment

by:asp_net2
ID: 37787776
Hi sedgwick,

Are you still able to help?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37792891
open the command window and run the batch from there, if there's an error u should be able to see it.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37792897
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now