Use it from the default path if found.

This commit is contained in:
Lars Brubaker 2014-11-18 16:24:43 -08:00
parent b81dfc010f
commit 1bf63e3554

View file

@ -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]