jmoleary
Posts: 39
Joined: Mon May 13, 2019 7:30 pm

How can I make this custom driver install step work?

Wed Jan 26, 2022 12:45 am

I want my installer to run a simple Windows command that uses an .INF file to install a driver. I want to make AI (Professional) do the equivalent of this Windows command line command

Code: Select all

pnputil -i -a ximeausbx64.inf
This command works just fine when I personally run it from the Windows command line as an Admin. And my installer requires Admin privileges. But I cannot figure out how to make AI do this for me.

I added the folder with the .INF and all needed files to the APPDIR as a subfolder (called "XimeaUsbDrivers"). Then I tried to add some Custom Actions.

First I rejected using Launch File and Launch Installed File because they seem to require an EXE, MSI or some other type but not a Windows batch file
Next I rejected Execute inline script code only allows for VBS or Javascript

But the Run PowerShell inline script step seemed promising. I googled around and found what looks to be a powershell command that will do it

Code: Select all

Get-ChildItem "C:\mydrivers\" -Recurse -Filter "*.inf" | 
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }

So I just need to change
C:\mydrivers\
to be... whatever the installed path of XimeaUsbDrivers is.

And I tried to do that. Tried to give the script an argument of [APPDIR]\XimeaUsbDrivers. Tried to make the script take it as an argument and pass it to the command. I cannot get it right. The installer runs but this step never seems to happen. The drivers do not get installed. The installer log file tells me nothing.

Am I doing this totally wrong? Can someone point me in the right direction?

-Joe

Liviu
Posts: 1035
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: How can I make this custom driver install step work?

Wed Jan 26, 2022 10:56 am

Hi Joe,

In order to achieve this, you have multiple options:

1. You can directly launch a CMD or .BAT file using the "Launch file" custom action. You can pass the folder parameter and even the file path to your script:

bat file.png
bat file.png (55.22KiB)Viewed 3124 times

Please have a look on our How to launch a CMD or BAT file article for more details.

2. You can pass the folder/file parameter to your PowerShell script like this:

PS parameter.png
PS parameter.png (156.6KiB)Viewed 3124 times

More details on the Run Inline PowerShell Script article - "Getting a property value into a script (for deferred custom actions)" section.

Please note that when you type "[" in the parameter field multiple options appear which allow you to select a file or folder directly.

You can also find your folder identifier by right clicking on it and select "Properties":
folder identifier.png
folder identifier.png (113.58KiB)Viewed 3124 times

Hope this helps! If you have any other questions, please don’t hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

jmoleary
Posts: 39
Joined: Mon May 13, 2019 7:30 pm

Re: How can I make this custom driver install step work?

Fri Jan 28, 2022 1:30 am

Thank you. This was an extremely helpful reply. I managed to make it work

Liviu
Posts: 1035
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: How can I make this custom driver install step work?

Fri Jan 28, 2022 8:53 am

You're welcome!

I'm glad you got this working.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”