pnputil.exe is not recognized as an internal or external command [closed] - windows

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
When i executed the command via command propmt to install the driver :
cd C:\Windows\System32
pnputil.exe -i -a "C:\Users\Desktop\Drivers\IPEnabled_001.inf"
It work fine.
But if i execute the command in Installanywhere tool
It showing the error message:
pnputil.exe is not recognized as an internal or external command
So could you please tell why it is showing the error message and how the reslove that error?
Thanks in advance.
Please also suggest the alternate way to install inf driver

pnputil.exe is on 64-bit Windows available only as 64-bit application which means there is %SystemRoot%\System32\pnputil.exe (x64) but no %SystemRoot%\SysWOW64\pnputil.exe (x86).
Which directory becomes current directory on using cd C:\Windows\System32 depends on 64-bit Windows on architecture of the application which started Windows command interpreter cmd.exe. A 64-bit application starts really %SystemRoot%\System32\cmd.exe, but a 32-bit application starts %SystemRoot%\SysWOW64\cmd.exe. The reason is the Windows File System Redirector which redirects any file access to %SystemRoot%\System32 to the directory %SystemRoot%\SysWOW64 on Windows x64 for x86 applications.
It is best to check for existence of this file before executing it for this task running pnputil.exe existing only in directory %SystemRoot%\System32 on any Windows independent on Windows architecture.
if exist %SystemRoot%\System32\pnputil.exe (
set "SystemPath=%SystemRoot%\System32"
) else if exist %SystemRoot%\Sysnative\pnputil.exe (
set "SystemPath=%SystemRoot%\Sysnative"
) else (
echo ERROR: Cannot find pnputil.exe to install the driver.
echo/
pause
goto :EOF
)
%SystemPath%\pnputil.exe -i -a "%USERPROFILE%\Desktop\Drivers\IPEnabled_001.inf"
The first IF condition is true for 32-bit applications on 32-bit Windows and 64-bit applications on 64-bit Windows.
The second IF condition is true for 32-bit applications on 64-bit Windows. Sysnative is a special redirector for x86 applications on Windows x64. Sysnative does not exist for x64 applications. Sysnative is not a directory or a symbolic link or a hard link. So it is not possible to use if exist %SystemRoot%\Sysnative as this condition is never true. It is required to check if a file exists in the redirected directory, for example with if exist %SystemRoot%\Sysnative\* which is only true on running currently 32-bit cmd.exe on 64-bit Windows.
The final ELSE branch is true for example on Windows XP which does not have pnputil.exe at all.
However, it is not recommended to use pnputil.exe to install drivers. Microsoft publishes for free the Driver Package Installer DPInst. There is a 32-bit (dpinst32.exe) and a 64-bit version (dpinst64.exe). Installation of one or more drivers is very easy using the driver package installer.
Let us look on how hardware producing companies which offer also the appropriate drivers like Intel ® install drivers using Driver Package Installer.
There is usually a directory structure in a driver installer package like:
VISTA32
VISTA64
WIN7-x86
WIN7-x64
XPx86
XPx64
Or a directory structure like:
VISTA
x86
x64
WIN7
x86
x64
XP
x86
x64
The directory structure varies from installer package to installer package, but that does not really matter and usually it is quite easy to see which driver files in which directory are for which version of Windows including architecture.
And there are additionally dpinst32.exe and dpinst64.exe being either stored in parent directory of all the subdirectories with the driver files or on just two driver directories directly in the directory containing the driver files.
Let us make the driver installation example very simple and assume there are only two driver files in a package, one for Windows x86 and one for Windows x64.
WIN-32
dpinst32.exe
*.cat
*.dll
*.inf
*.sys
WIN-64
dpinst64.exe
*.cat
*.dll
*.inf
*.sys
The code to install the 32-bit driver(s) in WIN-32 on 32-bit Windows and 64-bit driver(s) in WIN-64 on 64-bit Windows by a simple batch file executed either by 32-bit or 64-bit cmd.exe is very easy.
set "WINARCH=64"
if "%ProgramFiles(x86)%" == "" set "WINARCH=32"
cd WIN-%WINARCH%
dpinst%WINARCH%.exe
The environment variable ProgramFiles(x86) exists only on Windows x64 which makes it very easy to determine the architecture of Windows, see also WOW64 Implementation Details. The architecture of the processor does not really matter because on a PC with an AMD 64-bit (compatible) processor can be installed nevertheless a 32-bit Windows.
dpinst32.exe and dpinst64.exe started without any option simply install all drivers found in current directory.

Related

which file can install a program on windows 7?

Which of these files( in setup folder), if execute can install a program on windows 7 ?
1- setup.com
2-setup.ini
3-setup.inf
COM files are executable in Windows. You should be able to run setup.com from the CMD prompt by cding to the directory setup.com is in, and running setup or setup.com.
Keep in mind, COM files cannot be executed on 64-bit versions of Windows, since these editions lack NTVDM, the MS-DOS-emulating subsystem that handles COM file execution. You would instead need to emulate the 32-bit environment using an emulator like DOSBox.
setup.inf can be used to file copy and installation. I cannot remember setup.com installers for Windows programs.
msdn inf description

changing drivers through batch file

Is there a way to forcibly change drivers for particular devices in a batch file?
What my issue is here is that I'm trying to automate the process of selecting the correct driver for a projector that is connected to a computer and right now the projector is turned on automatically after the computer is started through a batch file.
However generic drivers are selected instead of the proper driver for that projector.
Is there a command I can use to forcibly change the driver for that projector or is there another way to change the default driver from the generic to the one I need automatically rather than manually?
In your batch file you need to find out:
Windows x86 (32 bit) or Windows x64 (64 bit) for example with:
if "%ProgramFiles(x86)%" == "" goto Driver32Bit
:Driver64Bit
echo Detected Windows x64
rem Commands for installing correct 64 bit driver after determining Windows version.
goto :EOF
:Driver32Bit
echo Detected Windows x86
rem Commands for installing correct 32 bit driver after determining Windows version.
goto :EOF
Windows version using command ver for selecting correct driver directory.
In each directory containing the driver files for appropriate Windows there should be dpinst32.exe or dpinst64.exe to install the driver. See Driver Package Installer (DPInst) for details about this free Microsoft application for installing drivers.
Very often the manufacturer of the driver delivers the driver packages already with dpinst32.exe and dpinst64.exe as often used by their own driver installers, too. Otherwise you need to download Windows Driver Kit and extract those two files from WDK package. Installing WDK is not necessary.

Using %PROGRAMFILES(x86)% on Windows OS 32bit

What happens when I use the environment variable %PROGRAMFILES(x86)% on a Windows OS that is 32bit (ie, older versions of Windows such as Windows XP, Vista)?
I am hoping that it will simply resolve to: C:/Program Files. Will this occur?
According to this the environment variable %PROGRAMFILES(x86)% is only available on 64-bit systems.
However, if you are on a 64-bit system and use %PROGRAMFILES%, the result you get depend on whether the process requesting the environment variable is 32-bit or 64-bit.
So from a 64-bit process on a 64-bit system you would get C:\Program Files, from a 32-bit process on a 64-bit system you would get C:\Program Files (x86), and from a 32-bit process on a 32-bit system you would get C:\Program Files.
If this doesn't help, perhaps you can comment or edit your original question to make it specific what you are trying to do. As it currently stands, the answer to your question is "No".
Keith Hill answered this question here, summary:
${env:ProgramFiles(x86)} is not defined on a 32-bit machine
If you always want to put/get data to/from x86 directory, then you can use this code to determine file paths:
$file = "\file"
if ("${Env:ProgramFiles(x86)}")
{
$fullPath = "${Env:ProgramFiles(x86)}\$file"
}
else
{
$fullPath = "${Env:ProgramFiles}\$file"
}
Since %ProgramFiles(x86)% is not defined on Windows 7 32 bit, here is a workaround I came up with:
SET MyPath="%ProgramFiles(x86)%\MyFolder\MyApplication.exe"
rem workaround for Windows7 32 bit:
IF NOT DEFINED ProgramFiles(x86) SET MyPath="%PROGRAMFILES%\MyFolder\MyApplication.exe"
Use case: I want to call an application from a batch file that is installed:
on Windows 7 32 bit in C:\Program Files\MyFolder\MyApplication.exe
on Windows 7 64 bit in C:\Program Files(x86)\MyFolder\MyApplication.exe
This way %MyPath% always points to the correct path.
If you use %programfiles% on a 32-bit computer/laptop it will open C:\Program Files.
If you use %programfiles% on a 64-bit computer/laptop it will open C:\Program Files.
If you have a 64-bit program installed on a 32-bit computer/laptop, it will be installed in a new folder named Program Files (x64), which is located in the "C" drive. In which case you have to use %programfiles(x64).
If you have a 32-bit program installed on a 64-bit computer/laptop, it will be installed in a new folder named Program Files (x86), which is located in the "C" drive. In which case you have to use %programfiles(x86).

What is PnPUtil.exe location in 64bit systems?

I would like to install my USB device driver [.inf file] using PnPUtil.exe utility on both 32bit and 64bit systems for Windows Vista and Windows 7.
I tested on my machine [Windows 7 32bit] and everything was fine because PnpUtil.exe is located in: C:\Windows\System32\PnPUtil.exe.
But in 64bit Windows 7 the utility is not in this directory.
When I tried installing driver on different Windows 7 - 64bit machine I could found PnPUtil.exe in this location: C:\WIndows\winsxs\amd64_microsoft-windows-pnputil_31bf3856ad364e35_6.1.7600.16385_none_5958b438d6388d15\pnputil.exe
and the test was also fine.
So how can I exactly detect this directory on all platforms?
I noticed the path is dependent on built of Windows version - 6.1.7600.16385 - but how to detect the rest of path?
Or is the path always the same on all 64 bit platforms? And what about Vista?
The location of PnPUtil.exe seen from you installer application depends on the bitness of your installer:
32bit installer on 32bit Windows: %WinDir%\System32
64bit installer on 64bit Windows: %WinDir%\System32
32bit installer on 64bit Windows: %WinDir%\Sysnative (Windows Vista and up)
More info here:
http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
I recently came across this problem while trying to create an installer for ReplicatorG, which includes the Arduino drivers and some drivers specific to the Makerbot Replicator.
It seemed that there isn't any way to determine the location of PnPutil, and I instead had to acquire Microsoft's DIFx and use their redistributable DPinst.
There were a couple of strange things about DPinst that made it difficult to use. The first is that it didn't seem to run properly if it was located in a directory tree with spaces in the path. Who knows why. The second was that, because the Arduino drivers are unsigned, it needed to be run in legacy mode to keep from popping up a big, red dialog warning the user. To run it in legacy mode you use the /lm flag, but the flag must be lowercase. Again, it's unclear why.
In the end, I had the installer copy dpinst and each of the drivers to a folder in the temporary directory and then run dpinst. It pops up a nice little wizard and tells the user which drivers were installed.
From C:\WIndows\winsxs\
dir /s PnPUtil.*
will scan subdirectories

Launching 64-bit executable from 32-bit Windows app

What is the "correct" way for a 32-bit application to find the "Program Files" folder on 64-bit Windows? For example, I am running a 32-bit application with a VBScript engine, and want to launch 64-bit Excel (using ShellExec, or similar). In the 32-bit world, I would check the environment variable "ProgramFiles" to get the base folder. My understanding is that as a 32-bit app on a 64-bit Windows, that environment variable will point to the 32-bit program files folder - eg: C:\Program Files(x86). But my 64-bit Excel will be under C:\Program Files.
I want to avoid hard-coding a reference to "c:\program files".
You can check the environment variable "ProgramW6432". It should exist and point to Program Files, without the x86, when running a 32bit application on a 64bit Windows.
Documentation: MSDN
Depending on the version of windows, you should be using the known folders apis.
http://msdn.microsoft.com/en-us/library/bb776911%28v=VS.85%29.aspx
Specifically you can use FOLDERID_ProgramFilesX64 in conjunction with SHGetKnownFolderPath.

Resources