How to use devcon.exe in C# (or other ways to install driver and ping a Hardware ID without infInstall)?

1.3k Views Asked by At

I'm finishing a helper about driver.

Begining, I use DPInst but it can't work in any arguments.

Devcon is available when a batch file call up like devcon install xxxxxxx.inf *xxxxxxx. It needs to edit the devcon.exe's UAC to open. In c# I never worked it.

All the batch command to upgrade permission are failed.

Is there any lib to install the driver without infInstall? Can't work on my driver. I must to point the HardwareID.

Try to call the devcon in cmd:

        System.Diagnostics.Process p = new System.Diagnostics.Process();
        p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.Verb = "runas";
        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.Arguments = SourcePath + @"\\x64" + @"\\devcon.exe install xxxx.inf xxxxxxx ";
        p.Start();

It also does not work and returns "devcon.exe failed". I guess it's caused by UAC.

0

There are 0 best solutions below