在上一篇網卡的Enable與Disable方法中, 在Intel Wi-Fi 6 AX200 160MHz的網卡上控制會有問題.
所以就試著用Netsh 去控制, 結果很幸運可以動作
圖一: 手動測試Netsh
用C# 寫的函式
public void Enable(string interfaceName)
{
try
{
var process = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = "C:\\Windows\\System32\\netsh.exe",
Arguments = "interface set interface \"" + interfaceName + "\" enable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
process.Start();
process.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public void Disable(string interfaceName)
{
try
{
var process = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = "C:\\Windows\\System32\\netsh.exe",
Arguments = "interface set interface \"" + interfaceName + "\" disable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
process.Start();
process.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
沒有留言:
張貼留言