I have a network profile for a 802.x network which works just fine when run from a batch file or cmd:
wlan add profile filename="config.xml"
So I thought I might as well do this on my C# programme by running a Process:
Process process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "netsh.exe",
Arguments = String.Format(@"wlan add profile filename=""{0}""", "config.xml"),
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
process.Start();
I asume that the file is being read alright, since otherwise it would output that the file has not been found. That is the C# error output message:
Profile format error 0x80420011: The connection profile is damaged.
But the config.xml is exactly the same!
I also tried running it in a more simple way, but the output is still the same:
string strCmd = "/C netsh wlan add profile filename=\"config.xml\"";
Process.Start("CMD.exe", strCmd);
Is there anything am I missing on my C# code so that this netsh command can be executed correctly?
Edit:
Console, Batch and C# commands were all run with user permissions. However, I tried running the C# one with administrator permissions as well, and it didn't work either.
User contributions licensed under CC BY-SA 3.0