'Executing pnputil commands via C#
I'm trying to execute pnputil commands via C#
When I execute plain command on Powershell, it's successful.
pnputil /disable-device "USB\VID_054C&PID_06C3\0500624"
https://i.imgur.com/Tl2jGrV.png
But if I run this command from C#, it fails
using (var process = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = @"Powershell.exe";
startInfo.Arguments = "/c pnputil /disable-device \"USB\\VID_054C&PID_06C3\\0500624\"";
startInfo.Verb = "runas";
process.StartInfo = startInfo;
process.Start();
}
This code returns the following error:
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
https://i.imgur.com/OFrFxaR.png
How can I fix the C# code?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
