Old 22nd November 2011, 18:32   #1
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
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
Elmi is offline   Reply With Quote
Old 23rd November 2011, 07:36   #2
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
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.

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 23rd November 2011, 10:36   #3
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
Hi,

I'm using Win 7
Elmi is offline   Reply With Quote
Old 27th November 2011, 16:01   #4
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
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?
Elmi is offline   Reply With Quote
Old 27th November 2011, 16:11   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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!
MSG is offline   Reply With Quote
Old 27th November 2011, 16:28   #6
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
I'm sure I don't have administrative access because pnputil fails. Therefore my question: how can I get administrative privileges for "Exec" calls?
Elmi is offline   Reply With Quote
Old 27th November 2011, 17:12   #7
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
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?
Elmi is offline   Reply With Quote
Old 28th November 2011, 05:38   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 20th December 2011, 10:07   #9
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
Quote:
Originally Posted by MSG View Post
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?
Elmi is offline   Reply With Quote
Old 20th December 2011, 11:09   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 20th December 2011, 13:25   #11
Elmi
Junior Member
 
Join Date: Nov 2011
Posts: 14
Quote:
Originally Posted by Afrow UK View Post
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!
Elmi is offline   Reply With Quote
Old 20th December 2011, 14:15   #12
Theresias
Junior Member
 
Join Date: Jun 2006
Posts: 48
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.
Theresias is offline   Reply With Quote
Old 21st December 2011, 08:13   #13
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
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.

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 25th July 2016, 17:50   #14
oakolawole
Junior Member
 
Join Date: Jul 2016
Posts: 4
Hi Guys

I am having the same problem trying to install an inf file using utilpnp but not succeeding using NSIS.

Someone said use DPInst but did not provide directions.

I would prefer to use utilpnp because when I type in the command, the inf file is installed. I just need to be able to do it from within the script. Hence my Installer user will not need to run the script.

Please help
oakolawole is offline   Reply With Quote
Old 25th July 2016, 17:51   #15
oakolawole
Junior Member
 
Join Date: Jul 2016
Posts: 4
Did you solve this problem. How did you solve it. I am having the same problem.

Thanks
oakolawole is offline   Reply With Quote
Old 26th July 2016, 15:33   #16
stass
Senior Member
 
Join Date: Nov 2012
Posts: 165
code:
${If} ${RunningX64}
ExecWait '"$INSTDIR\drivers\dpinst64.exe" /c /sa /lm /se /sw /PATH "$INSTDIR\drivers\drv.inf"'
${Else}
ExecWait '"$INSTDIR\drivers\dpinst32.exe" /c /sa /lm /se /sw /PATH "$INSTDIR\drivers\drv.inf"'
${EndIf}


http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

or

code:
ExecWait '$SYSDIR\RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 INSTDIR\<myinf>.inf'

http://msdn.microsoft.com/ru-ru/libr...(v=vs.85).aspx
stass is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
.inf, driver, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump