diff --git a/PrinterDriverInstaller/InfInstaller.cs b/PrinterDriverInstaller/InfInstaller.cs index 0ef47670d..ba4b1e339 100644 --- a/PrinterDriverInstaller/InfInstaller.cs +++ b/PrinterDriverInstaller/InfInstaller.cs @@ -38,16 +38,21 @@ namespace MatterHackers.InfInstaller string pnpUtilFileName = "PnPUtil.exe"; - string pnPUtilPathAndFileName = Path.Combine("C:/WIndows/winsxs/amd64_microsoft-windows-pnputil_31bf3856ad364e35_6.1.7600.16385_none_5958b438d6388d15", pnpUtilFileName); + string pnPUtilPathAndFileName = Path.Combine("C:/Windows/winsxs/amd64_microsoft-windows-pnputil_31bf3856ad364e35_6.1.7600.16385_none_5958b438d6388d15", pnpUtilFileName); + bool fileExists = File.Exists(pnPUtilPathAndFileName); - // Disable redirection - IntPtr ptr = new IntPtr(); - bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr); - if (isWow64FsRedirectionDisabled) + if (!fileExists) { - pnPUtilPathAndFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), 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; @@ -56,8 +61,12 @@ namespace MatterHackers.InfInstaller driverInstallerProcess.WaitForExit(); - // Restore redirection - Wow64RevertWow64FsRedirection(ptr); + if (!fileExists) + { + // Restore redirection + IntPtr ptr = new IntPtr(); + Wow64RevertWow64FsRedirection(ptr); + } } [STAThread]