Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Remove IE9 using WMI

Posted on 2012-03-28
11
Medium Priority
?
709 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:
Meir Rivkin 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:Meir Rivkin
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 42

Expert Comment

by:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
ID: 37792897
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

876 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