WMI问题求助
代码如下: 
 			try 
 			{ 
 				ManagementObject   classInstance   =    
 					new   ManagementObject( "root\\CIMV2 ",    
 					 "Win32_Service.Name= 'wuauserv ' ", 
 					null);   
 				//   no   method   in-parameters   to   define     
 				//   Execute   the   method   and   obtain   the   return   values. 
 				ManagementBaseObject   outParams   =    
 					classInstance.InvokeMethod( "StartService ",   null,   null);   
 				//   List   outParams 
 				this.Label1.Text   =   outParams[ "ReturnValue "].ToString(); 
 				Console.WriteLine( "Out   parameters: "); 
 				Console.WriteLine( "ReturnValue:    "   +   outParams[ "ReturnValue "]); 
 			} 
 			catch(ManagementException   err) 
 			{ 
 				//MessageBox.Show( "An   error   occurred   while   trying   to   execute   the   WMI   method:    "   +   err.Message); 
 				this.Label1.Text   =   err.Message; 
 			}  			   
 此段代码,如果做成应用程序运行,那么启动服务没有问题。 
 但是如果写在网页内(即aspx),则无法启动服务,ReturnValue为2 
 注:我的目的是在服务器上提供个网页,远端用户可以通过访问这个网页来打开或关闭服务器上的某个service。   
 如果按照远程计算机方式访问,即   使用\\localhost\root\CIMV2:Service,结果显示无法为本地连接使用用户凭证。   
 我一度认为是iis的权限不够,无法操作服务,但是把iisadmin和www两个服务都使用administrator登陆后,反而本地网站都打不开了。   
 请教大家,该如何是好     
------解决方案--------------------建立一个WebService,然后把你的代码做为一个WebService的方法来调用如何?
------解决方案--------------------machine.config    
  <processModel ..... user=administrator password=adminpassword 
------解决方案--------------------查了以前写的,需要用impersonate来模拟用户,需要修改web.config文件,增加 
  <identity impersonate= "true "  
   userName= "机器名\用户名 "  
   password= "密码 " />    
 至于服务的控制,可以用servicecontroller来完成,例如: 
 			ServiceController[] scs = ServiceController.GetServices(); 
 			foreach( ServiceController sc in scs ) 
 				if( sc.ServiceName ==  "MSSQLSERVER " ) 
 				{ 
 					if( sc.CanStop ) 
 					{ 
 						sc.Stop(); 
 						sc.WaitForStatus( ServiceControllerStatus.Stopped ); 
 					} 
 					break; 
 				}