diff --git a/MatterControl.csproj b/MatterControl.csproj
index 3d864224f..0120a1213 100644
--- a/MatterControl.csproj
+++ b/MatterControl.csproj
@@ -425,5 +425,9 @@
{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}
Agg
+
+ {990a9ad3-b6a4-407b-9dfc-9c722af7c9b9}
+ InfInstaller
+
\ No newline at end of file
diff --git a/MatterControl.sln b/MatterControl.sln
index 9740fd76e..bc00b54e1 100644
--- a/MatterControl.sln
+++ b/MatterControl.sln
@@ -95,6 +95,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudServices", "..\CloudSe
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agg-sharp", "agg-sharp", "{2AB9B589-5C98-4C05-BBEA-F97DAE168EAB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InfInstaller", "PrinterDriverInstaller\InfInstaller.csproj", "{990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -627,6 +629,26 @@ Global
{6782BF37-8139-4DC6-885E-98D22D1FB258}.Release64|Any CPU.Build.0 = Release|Any CPU
{6782BF37-8139-4DC6-885E-98D22D1FB258}.Release64|x64.ActiveCfg = Release|Any CPU
{6782BF37-8139-4DC6-885E-98D22D1FB258}.Release64|x86.ActiveCfg = Release|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug|x64.ActiveCfg = Debug|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug|x64.Build.0 = Debug|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug64|Any CPU.ActiveCfg = Debug64|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug64|Any CPU.Build.0 = Debug64|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug64|x64.ActiveCfg = Debug64|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug64|x64.Build.0 = Debug64|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Debug64|x86.ActiveCfg = Debug64|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release|x64.ActiveCfg = Release|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release|x64.Build.0 = Release|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release|x86.ActiveCfg = Release|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release64|Any CPU.Build.0 = Release64|Any CPU
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release64|x64.ActiveCfg = Release64|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release64|x64.Build.0 = Release64|x64
+ {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}.Release64|x86.ActiveCfg = Release64|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PrinterControls/PrinterConnections/SetupStepInstallDriver.cs b/PrinterControls/PrinterConnections/SetupStepInstallDriver.cs
index d8af82688..bd5a541e5 100644
--- a/PrinterControls/PrinterConnections/SetupStepInstallDriver.cs
+++ b/PrinterControls/PrinterConnections/SetupStepInstallDriver.cs
@@ -116,53 +116,23 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
if (Path.GetExtension(fileName).ToUpper() == ".INF")
{
- var driverInstallerProcess = new Process();
+ Process driverInstallerProcess = new Process();
// Prepare the process to run
// Enter in the command line arguments, everything you would enter after the executable name itself
- driverInstallerProcess.StartInfo.Arguments = "/a {0}".FormatWith(Path.GetFullPath(fileName));
+
+ driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
+ // Enter the executable to run, including the complete path
+ string printerDriverInstallerExePathAndFileName = Path.Combine(".", "InfInstaller.exe");
driverInstallerProcess.StartInfo.CreateNoWindow = true;
driverInstallerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
- string pnpUtilFileName = "PnPUtil.exe";
- string pnPUtilPathAndFileName = "";
- string[] locationsToTry =
- {
- "C:/Windows/System32",
- "C:/WIndows/winsxs/amd64_microsoft-windows-pnputil_31bf3856ad364e35_6.1.7600.16385_none_5958b438d6388d15",
- };
- // find the location of pnputil.exe
- for(int i=0; i files = new List(Directory.GetFiles("C:/Windows/winsxs", pnpUtilFileName, SearchOption.AllDirectories));
- if(files.Count > 0)
- {
- pnPUtilPathAndFileName = files[0];
- }
- }
- if (pnPUtilPathAndFileName != "")
- {
- driverInstallerProcess.StartInfo.FileName = pnPUtilPathAndFileName;
- driverInstallerProcess.StartInfo.Verb = "runas";
- driverInstallerProcess.StartInfo.UseShellExecute = true;
-
- driverInstallerProcess.Start();
-
- driverInstallerProcess.WaitForExit();
-
- // Retrieve the app's exit code
- var exitCode = driverInstallerProcess.ExitCode;
- }
+ driverInstallerProcess.Start();
+ driverInstallerProcess.WaitForExit();
}
else
{
diff --git a/PrinterDriverInstaller/InfInstaller.cs b/PrinterDriverInstaller/InfInstaller.cs
index 16d13a446..eb2138390 100644
--- a/PrinterDriverInstaller/InfInstaller.cs
+++ b/PrinterDriverInstaller/InfInstaller.cs
@@ -15,20 +15,47 @@ namespace MatterHackers.InfInstaller
{
public class InfInstallerApp
{
- [DllImport("Setupapi.dll", EntryPoint = "InstallHinfSection", CallingConvention = CallingConvention.StdCall)]
- public static extern void InstallHinfSection(
- [In] IntPtr hwnd,
- [In] IntPtr ModuleHandle,
- [In, MarshalAs(UnmanagedType.LPWStr)] string CmdLineBuffer,
- int nCmdShow);
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
public InfInstallerApp()
{
+ Debugger.Launch();
}
public void InstallInfDriverFile(string pathAndDriverToInstall)
{
- InstallHinfSection(IntPtr.Zero, IntPtr.Zero, pathAndDriverToInstall, 0);
+ Process driverInstallerProcess = new Process();
+
+ driverInstallerProcess.StartInfo.Arguments = "/a {0}".FormatWith(Path.GetFullPath(pathAndDriverToInstall));
+
+ driverInstallerProcess.StartInfo.CreateNoWindow = true;
+ driverInstallerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+
+ string pnpUtilFileName = "PnPUtil.exe";
+
+ string pnPUtilPathAndFileName = Path.Combine("C:/WIndows/winsxs/amd64_microsoft-windows-pnputil_31bf3856ad364e35_6.1.7600.16385_none_5958b438d6388d15", pnpUtilFileName);
+
+ // Disable redirection
+ IntPtr ptr = new IntPtr();
+ bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
+ if (isWow64FsRedirectionDisabled)
+ {
+ pnPUtilPathAndFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), pnpUtilFileName);
+ }
+
+ driverInstallerProcess.StartInfo.FileName = pnPUtilPathAndFileName;
+ driverInstallerProcess.StartInfo.Verb = "runas";
+ driverInstallerProcess.StartInfo.UseShellExecute = true;
+
+ driverInstallerProcess.Start();
+
+ driverInstallerProcess.WaitForExit();
+
+ // Restore redirection
+ Wow64RevertWow64FsRedirection(ptr);
}
[STAThread]
diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt
index 5a5fe384c..cf2f765c0 100644
--- a/StaticData/Translations/Master.txt
+++ b/StaticData/Translations/Master.txt
@@ -2849,3 +2849,6 @@ Translated:{0} is not available
English:Invalid printer response
Translated:Invalid printer response
+English:Could not find a selected button.
+Translated:Could not find a selected button.
+