PDA

View Full Version : Custom Action: Launch Application Rundll32 printui



lmilesuk
11-18-2014, 08:52 AM
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.

MichaelU
11-18-2014, 09:53 AM
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.

lmilesuk
11-18-2014, 11:29 AM
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, &&.?

MichaelU
11-19-2014, 09:02 AM
For that you'll have to build the string up at run time. See the string operators (http://helpnet.flexerasoftware.com/installshield21helplib/installshield21helplib.htm#StartTopic=Subsystems/installshield21langref/helplibrary/LangrefString_operators___.htm), particularly + and ^ depending on which parts you know ahead of time and what you're concatenating together.