EDN Admin
Well-known member
Hello,
From my C# winforms app, I install tap adapter. It installs but multiple times. Like in 32bit systems, it asks for "Uncertified logo .... " with 2 buttons "Continue Anyways" and "Stop Anyway". If you press once "Continue.." btn still it asks
the same question untill you press "Stop Anyway". Any how many times you clicked "Continue..." the adapter is installed that many times. Like if you clicked 4 times "Continue ..." button, 4 adapters are installed on the system.
In 64bit system, it acts little bit differently. It asks if you want to install Y/N. You click Yes and it installs 2 times and the chapter is over. It wont ask another time or so, but in once only it will install 2 adapters. Here is the code
that I have implemented :
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; bool InstallTapAdapter()
{
<span style="color:Blue; bool installed = <span style="color:Blue; false;
ProcessStartInfo processInfo = <span style="color:Blue; null;
Process process = <span style="color:Blue; null;
<span style="color:Blue; try
{
<span style="color:Blue; string path = Utility.FILES_PATH;
<span style="color:Green; // Select driver dir based on system bit
<span style="color:Blue; if (is64bitSystem)
path = Path.Combine(Utility.FILES_PATH, <span style="color:#A31515; "tapWin64");
<span style="color:Blue; else
path = Path.Combine(Utility.FILES_PATH, <span style="color:#A31515; "tapWin32");
<span style="color:Blue; string command = <span style="color:#A31515; "";
command = <span style="color:#A31515; "tapinstall install "OemWin2k.inf" tap0901";
processInfo = <span style="color:Blue; new ProcessStartInfo(<span style="color:#A31515; "cmd.exe", <span style="color:#A31515; "/C " + command);
processInfo.UseShellExecute = <span style="color:Blue; false;
processInfo.RedirectStandardOutput = <span style="color:Blue; true;
processInfo.RedirectStandardError = <span style="color:Blue; true;
processInfo.CreateNoWindow = <span style="color:Blue; true;
processInfo.WorkingDirectory = path;
Console.WriteLine(<span style="color:#A31515; "Installing tap");
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Installing tap");
process = <span style="color:Blue; new Process();
process.StartInfo = processInfo;
process.Start();
<span style="color:Blue; string str = process.StandardOutput.ReadToEnd();
<span style="color:Blue; string err = process.StandardError.ReadToEnd();
<span style="color:Blue; int exitCode = process.ExitCode;
<span style="color:Blue; if (err.Length > 0)
<span style="color:Blue; throw <span style="color:Blue; new Exception(err);
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "COMPLETED Installing tap Exit code = " + exitCode);
<span style="color:Blue; if (str.IndexOf(<span style="color:#A31515; "Drivers installed successfully") > -1)
{
installed = <span style="color:Blue; true;
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Tap Adapter Installed Successfully");
}
Console.WriteLine(<span style="color:#A31515; "Finished TAP");
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Finished TAP");
}
<span style="color:Blue; catch (Exception e)
{
UltimateLibrary.io.Logger.LogError(<span style="color:#A31515; "Errror Installing Tap Adapter : " + e.Message);
}
<span style="color:Blue; finally
{
processInfo = <span style="color:Blue; null;
<span style="color:Blue; if (process != <span style="color:Blue; null)
{
process.Close();
process = <span style="color:Blue; null;
}
}
<span style="color:Blue; return installed;
}
[/code]
Why is this strange behaviour ? Has anyone experienced the same ? Is any settings or so required for the windows to stop it acting like this ?
Any help is highly appreciated.
<hr class="sig Thanks
View the full article
From my C# winforms app, I install tap adapter. It installs but multiple times. Like in 32bit systems, it asks for "Uncertified logo .... " with 2 buttons "Continue Anyways" and "Stop Anyway". If you press once "Continue.." btn still it asks
the same question untill you press "Stop Anyway". Any how many times you clicked "Continue..." the adapter is installed that many times. Like if you clicked 4 times "Continue ..." button, 4 adapters are installed on the system.
In 64bit system, it acts little bit differently. It asks if you want to install Y/N. You click Yes and it installs 2 times and the chapter is over. It wont ask another time or so, but in once only it will install 2 adapters. Here is the code
that I have implemented :
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; bool InstallTapAdapter()
{
<span style="color:Blue; bool installed = <span style="color:Blue; false;
ProcessStartInfo processInfo = <span style="color:Blue; null;
Process process = <span style="color:Blue; null;
<span style="color:Blue; try
{
<span style="color:Blue; string path = Utility.FILES_PATH;
<span style="color:Green; // Select driver dir based on system bit
<span style="color:Blue; if (is64bitSystem)
path = Path.Combine(Utility.FILES_PATH, <span style="color:#A31515; "tapWin64");
<span style="color:Blue; else
path = Path.Combine(Utility.FILES_PATH, <span style="color:#A31515; "tapWin32");
<span style="color:Blue; string command = <span style="color:#A31515; "";
command = <span style="color:#A31515; "tapinstall install "OemWin2k.inf" tap0901";
processInfo = <span style="color:Blue; new ProcessStartInfo(<span style="color:#A31515; "cmd.exe", <span style="color:#A31515; "/C " + command);
processInfo.UseShellExecute = <span style="color:Blue; false;
processInfo.RedirectStandardOutput = <span style="color:Blue; true;
processInfo.RedirectStandardError = <span style="color:Blue; true;
processInfo.CreateNoWindow = <span style="color:Blue; true;
processInfo.WorkingDirectory = path;
Console.WriteLine(<span style="color:#A31515; "Installing tap");
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Installing tap");
process = <span style="color:Blue; new Process();
process.StartInfo = processInfo;
process.Start();
<span style="color:Blue; string str = process.StandardOutput.ReadToEnd();
<span style="color:Blue; string err = process.StandardError.ReadToEnd();
<span style="color:Blue; int exitCode = process.ExitCode;
<span style="color:Blue; if (err.Length > 0)
<span style="color:Blue; throw <span style="color:Blue; new Exception(err);
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "COMPLETED Installing tap Exit code = " + exitCode);
<span style="color:Blue; if (str.IndexOf(<span style="color:#A31515; "Drivers installed successfully") > -1)
{
installed = <span style="color:Blue; true;
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Tap Adapter Installed Successfully");
}
Console.WriteLine(<span style="color:#A31515; "Finished TAP");
UltimateLibrary.io.Logger.LogInfo(<span style="color:#A31515; "Finished TAP");
}
<span style="color:Blue; catch (Exception e)
{
UltimateLibrary.io.Logger.LogError(<span style="color:#A31515; "Errror Installing Tap Adapter : " + e.Message);
}
<span style="color:Blue; finally
{
processInfo = <span style="color:Blue; null;
<span style="color:Blue; if (process != <span style="color:Blue; null)
{
process.Close();
process = <span style="color:Blue; null;
}
}
<span style="color:Blue; return installed;
}
[/code]
Why is this strange behaviour ? Has anyone experienced the same ? Is any settings or so required for the windows to stop it acting like this ?
Any help is highly appreciated.
<hr class="sig Thanks
View the full article