The Guy
C# pnputil not recognized
public void InstallPrinter(PrinterInfo printer)
{
string script = $@"script to install printer. install driver using pnputil."
using (PowerShell ps = PowerShell.Create())
{
ps.AddScript(script);
try
{
var results = ps.Invoke();
if (ps.HadErrors)
{
foreach (var error in ps.Streams.Error)
{
Console.WriteLine($"Error: {error}");
}
}
else
{
foreach (var result in results)
{
Console.WriteLine(result.ToString());
}
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
I checked the log and the error occur during the driver installation and it's because it doesn't recognize pnputil. No problem running in powershell console.
19 replies