通过WMI获取启动列表

时间:2010-05-05 18:54:43

标签: c# wmi

如何获取完整的.exe路径

让我们假设使用以下字符串strt [“Command”]。ToString(); 我得到了这个输出

  

C:\ Program Files \ Analog   Devices \ SoundMAX \ soundmax.exe / tray

但是如何获得

  

C:\ Program Files \ Analog   设备\的SoundMAX \ soundmax.exe

ManagementClass mangnmt = new ManagementClass("Win32_StartupCommand");
ManagementObjectCollection mcol = mangnmt.GetInstances();
foreach (ManagementObject strt in mcol)
{
    string[] lv = new String[4];
    lv[0] = strt["Caption"].ToString();
    lv[1] = strt["Location"].ToString();
    lv[2] = strt["Command"].ToString();
    lv[3] = strt["Description"].ToString();
    listView1.Items.Add(new ListViewItem(lv, 0));
}

1 个答案:

答案 0 :(得分:0)

   FileInfo fi = new FileInfo(@"C:\Program Files\Analog Devices\SoundMAX\soundmax.exe /tray");
   Console.WriteLine(fi.DirectoryName);