通过 WMI 获取启动列表 [英] Get the Startup List via WMI
本文介绍了通过 WMI 获取启动列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取完整的 .exe 路径
How do I gat the the full .exe path
让我们假设以下字符串 strt["Command"].ToString();我得到这个输出
Let us assume with the following string strt["Command"].ToString(); I get this output
C:\Program Files\Analog设备\SoundMAX\soundmax.exe/tray
C:\Program Files\Analog Devices\SoundMAX\soundmax.exe /tray
但我如何获得
C:\Program Files\Analog设备\SoundMAX\soundmax.exe
C:\Program Files\Analog Devices\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));
}
推荐答案
FileInfo fi = new FileInfo(@"C:\Program Files\Analog Devices\SoundMAX\soundmax.exe /tray");
Console.WriteLine(fi.DirectoryName);
这篇关于通过 WMI 获取启动列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文