Here is the example to Install a .inf driver programmatically using C# .Net.

Installation of .inf driver using c# is easy. Please check the following code for that.

private static void driverInstall(string driverPath)

               var process = new Process();
               process.StartInfo.UseShellExecute = false;
               process.StartInfo.CreateNoWindow = true;
               process.StartInfo.RedirectStandardOutput = true;
               process.StartInfo.RedirectStandardError = true;
               process.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
               string a = @"" + driverPath + "";
               process.StartInfo.Arguments = "/c C:\\Windows\\Sysnative\\PnPutil.exe -a \"" + driverPath + "\""; // where driverPath is path of .inf file
               Console.WriteLine(@"Driver has been installed");
           catch (Exception ex)

Note: Please note that here I used Windows\Sysnative folder instead of Windows\system32 for PnPUtil.exe path. c:\windows\system32\pnputil.exe path is ok for 32bit system. But when you are working with a 64bit system, you must change path to c:\windows\sysnative\pnputil.exe.

You may face the following error during .inf driver installation using c#.

Error: pnputil.exe is not recognized as an internal or external command, operable program or batch file.


If you are using path “c:\windows\system32\PnPUtil.exe” for cmd arguments then you may face the error like “pnputil.exe is not recognized as an internal or external command, operable program or batch file”. The Solution is simple replace “c:\windows\system32\PnPUtil.exe” with  “c:\windows\sysnative\pnputil.exe” as per my above example. for more details you can visit: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019L4VSAU&l=en-IN


How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?