Archive: Install USB driver / .inf file - pnputil fails


Install USB driver / .inf file - pnputil fails
Hi,

I want to install an USB driver via its .inf file using NSIS. I found a Wiki-entry regarding this that recommended to use Microsofts pnputil to add the .inf file to the driver storage.

Unfortunately pnputil fails, it cancels the operation with an error message "Access denied". This is strange because I have administrator privileges.

So what can I do - how can I pre-install a driver/.inf file so that it is used as soon as the related device is attached?

Elmi


What version of Windows are you using?
For W2k and XP use these plug-ins: http://nsis.sourceforge.net/Driver_i...ion_and_update and http://nsis.sourceforge.net/InstDrv_plug-in

For Vista and later PnPUtil is better.


Hi,

I'm using Win 7


Hi,

I think I found the reason:

when executing pnputil within NSIS using command "Exec" it is NOT executed with administrator privileges although I previously called "RequestExecutionLevel admin".

So how can I execute pnputil WITH admin privileges correctly?


Are you sure you have administrative access? Note that requestexecutionlevel admin is NOT sufficient to guarantee it - you need to use the userinfo plugin (in .onInit) to verify!


I'm sure I don't have administrative access because pnputil fails. Therefore my question: how can I get administrative privileges for "Exec" calls?


May be I have to be more detailled:

When using "pnputil" manually I have to run a "cmd.exe" as administrator, elsewhere pnputil fails.

So to execute pnputil out of a NSIS installer I currently execute it using "Exec". But this does not seem to execute it within a "cmd" that has administrator privileges.

So how can I "Exec" it correctly so that the underlying command line environment has the same privileges like a "cmd.exe" that is executed with administrator privileges?


If your installer isn't at admin level, the pnputil also will not be executed at admin level. To make sure the installer's child processes are admin, make sure the installer is admin. To do this, use the userinfo plugin.


Originally posted by MSG
make sure the installer is admin. To do this, use the userinfo plugin.
OK, it tells me I'm not Admin - how do I change that?

Simplest approach is to bring up a message box and tell the user they must run the installer as an administrator using Run As (and then exit). Another option is you could run the installer again using ExecShell with the runas verb. Last option I suppose is to use the UAC plug-in.

Stu


Originally posted by Afrow UK
Simplest approach is to bring up a message box and tell the user they must run the installer as an administrator using Run As (and then exit).
OK, in this case we're back to my original problem: running the installer as Administrator DOES NOT cause pnputil to work properly since the command line that is spawned from such an installer seems not to inherit its privileges!

Save yourself the trouble and use DPInst instead, we've wasted our time with several approaches and after having tried them "all" we went with DPInst. In fact at this point we are very glad to have used as it also allows easy un-installation of specific driver versions.


I can confirm Theresias words: PnPUtil is not working correctly in some cases.
I made drivers installer some time ago and it was too difficult to find out why is PnPUtil causing troubles so I switched to DPInst.

Use DPInst - there is simple example here: http://blogs.technet.com/b/svengruen...pinst-exe.aspx
Also all necessary files are there so you do not need to download whole SDK package.