cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lmilesuk
Level 4

Custom Action: Launch Application Rundll32 printui

Hi,

I'm having trouble getting setting up a custom install script in a Basic MSI project, I want to be able to run the following cmd line command in installscript;


C:\Windows\SysWOW64\rundll32 printui.dll,PrintUIEntry /if /b "Printer Name" /f "c:\\windows\inf\oem12.inf" /r "Lpt1:" /m "Printer Name" /z /u;


I'm able to get make this work from the command line however whenever I try my LaunchApplication function it fails, I'm currently putting this as my LaunchApplication function;

LaunchApplication( WINSYSDIR64^"rundll32.exe", printui.dll,PrintUIEntry /if /b "Printer 1" /f "c:\\windows\inf\oem12.inf" /r "Lpt1:" /m "Printer 1" /z /u,
WINSYSDIR64, SW_HIDE, LAAW_OPTION_USE_SHELLEXECUTE, LAAW_OPTION_SHOW_HOURGLASS);


When compiling I get printui: undefined identifier.

Am I barking up the wrong tree and is it even possible as a custom install script action?

I can make it work as a custom action -> New EXE - Stored in a binary table, however I have lots of these I wish to add so would like to do it in script.

Any help would be much appreciated.

Thanks in advance.
Labels (1)
0 Kudos
(3) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

It looks like you have a slight misunderstanding about the InstallScript programming language. The error you received indicates that it's treating printui as the name of a variable. If you want to treat it as (part of) the name of a file, it must be turned into a string by putting it in quotes.

So instead of printui.dll your code should have "printui.dll". But since that's just part of the overall arguments to the program, you'll really need
"printui.dll,PrintUIEntry /if /b \"Printer 1\" /f \"c:\\windows\\inf\\oem12.inf\" /r \"Lpt1:\" /m \"Printer 1\" /z /u"
instead (note the embedded quotes that are escaped by backslashes). Note that I haven't verified the command itself; I've just tried to convert what you posted into something that the InstallScript compiler will understand.
0 Kudos
lmilesuk
Level 4

MichaelU wrote:
It looks like you have a slight misunderstanding about the InstallScript programming language. The error you received indicates that it's treating printui as the name of a variable. If you want to treat it as (part of) the name of a file, it must be turned into a string by putting it in quotes.

So instead of printui.dll your code should have "printui.dll". But since that's just part of the overall arguments to the program, you'll really need
"printui.dll,PrintUIEntry /if /b \"Printer 1\" /f \"c:\\windows\\inf\\oem12.inf\" /r \"Lpt1:\" /m \"Printer 1\" /z /u"
instead (note the embedded quotes that are escaped by backslashes). Note that I haven't verified the command itself; I've just tried to convert what you posted into something that the InstallScript compiler will understand.


If I wanted to place a string variable as a replacement to c:\\windows\\inf\\oem12.inf would I put in in ' ' i.e. '\szDestinationInfFileName' as I can't get the compiler to like any combination tried double quotes, &&.?
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

For that you'll have to build the string up at run time. See the string operators, particularly + and ^ depending on which parts you know ahead of time and what you're concatenating together.
0 Kudos