使用WMI从远程服务器获取反病毒更新 [英] using WMI to fetch anti virus updates from remote sever

查看:50
本文介绍了使用WMI从远程服务器获取反病毒更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用的WMI代码从
获取反病毒更新 我正在运行的计算机上,但是在尝试获取远程服务器的防病毒更新时,它抛出一个异常:无效的名称空间.
请帮助

Hi all,

the WMI code I am using fetches the anti virus updates from the
machine I am running on but while trying to fetch anti virus updates of the remote server it throws an exception: invalid namespace.
Please help

推荐答案

没有看到引发异常的代码,也不知道您使用的是哪种病毒软件,就不可能告诉你怎么了.
Without seeing the code around the line that''s throwing the exception and knowing which virus software you''re using, it''s impossible to tell you what''s wrong.


戴夫,
我的代码是这样的:

Hi Dave,
my code goes like this:

private void Form1_Load(object sender, EventArgs e)    {      
string MName= lstMachineName.SelectedItem.ToString();
label1.Text = "Company ="+Antivirus("companyName","MName");

     
 label2.Text = "Name =" +Antivirus("displayName", "MName");  
}    
private string Antivirus(string type,string MName)    
{      
   
string wmipath = @"\\" + MName@"\root\SecurityCenter";      
try
    {        
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipath,          "SELECT * FROM AntivirusProduct");        ManagementObjectCollection instances = searcher.Get();        
//MessageBox.Show(instances.Count.ToString());         
foreach (ManagementObject queryObj in instances)        
{          
return queryObj[type].ToString();        
}      
}      
catch (Exception e)     
 {       
 MessageBox.Show(e.Message);   
   }     
 return null;   
 }



该代码适用于computer.Environmenr或计算机名称为."(当前运行的计算机),但对于远程服务器计算机名称则抛出错误:无效的名称空间.



The code works fine for the computer.Environmenr or when machine name is "."(current running machine), but for remote server machine names its throwing an error:invalid namespace.


这篇关于使用WMI从远程服务器获取反病毒更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆