With the use of ManagementClass, a few lines of code will give us this list.
The WMI classes are easy to use such these operations.
- Add reference System.Management to your project.
- Add the following code to your code file.
using System.Management;
using System.Management.Instrumentation;
ManagementClass mangnmt =
new ManagementClass("Win32_StartupCommand");
ManagementObjectCollection mcol = mangnmt.GetInstances();
foreach (ManagementObject strt in mcol)
{
Console.WriteLine("Application Name: "
+ strt["Name"].ToString());
Console.WriteLine("Application Location: "
+ strt["Location"].ToString());
Console.WriteLine("Application Command: "
+ strt["Command"].ToString());
Console.WriteLine("User: " + strt["User"].ToString());
}
List Autorun programs in C#
1 comment:
You code does not work as it is missing several line ending and qualifiers.
Post a Comment