Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove IE9 using WMI

Posted on 2012-03-28
11
Medium Priority
?
707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 1500 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
Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

 
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
 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

664 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