Get the Startup List via WMI

这一生的挚爱 提交于 2019-12-12 04:28:03

问题


How do I gat the the full .exe path

Let us assume with the following string strt["Command"].ToString(); I get this output

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

but how to I get

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));
}

回答1:


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


来源:https://stackoverflow.com/questions/2775967/get-the-startup-list-via-wmi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!