Remove IE9 using WMI

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!
LVL 4
asp_net2Asked:
Who is Participating?
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
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
 
asp_net2Author Commented:
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
 
Meir RivkinFull stack Software EngineerCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Meir RivkinFull stack Software EngineerCommented:
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
 
asp_net2Author Commented:
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
 
Meir RivkinFull stack Software EngineerCommented:
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
 
asp_net2Author Commented:
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
 
asp_net2Author Commented:
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
 
asp_net2Author Commented:
Hi sedgwick,

Are you still able to help?
0
 
Meir RivkinFull stack Software EngineerCommented:
open the command window and run the batch from there, if there's an error u should be able to see it.
0
 
Meir RivkinFull stack Software EngineerCommented:
0
All Courses

From novice to tech pro — start learning today.