/build/static/layout/Breadcrumb_cap_w.png

Installing/Removing Printers with Custom Action Batch Files?

Hello,

I am working with tuning a package for RightFax Client 9.3 (FeaturePack 1b, Hotfix 3). To get the install working correctly in our environment, it appears that a LaserJet 4 printer be installed prior to installation. We do not have any LaserJet 4 printers in our environment, so I would prefer that the printer not stay in the "Printers & Faxes" listing of WinXP.

I've created two batch files which will accomplish adding and removing the printer;

To add:

rundll32 printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"

To remove:

rundll32 printui.dll,PrintUIEntry /dl /n "HPLJ4-RIGHTFAX"


I would like to tie these into custom actions somehow (I've never dealt with custom actions, so not sure if this is possible)

The optimal order would be;

1.) Script above to add LJ4 printer
2.) Install RightFax Client 9.3
3.) Script above to remove LJ4 printer

Is this possible with custom actions? If so, how would I go about completing this?

Thanks in advance.

*EDIT*
Also wanted to mention that this LJ4 printer is only temporary for the install process -- the installation needs to see a LJ4 sitting in 'Printers & Faxes' of WinXP.

0 Comments   [ + ] Show comments

Answers (9)

Posted by: bheers 17 years ago
Second Degree Blue Belt
0
Just before install initialize in Execute immediate

If Not Installed
execute program from destination [SystemFolder]rundll32.exe
Arguments = printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"
End

Before install finalize in execute deffered

If Not Installed
execute program from destination : [SystemFolder]rundll32.exe
Arguments = printui.dll,PrintUIEntry /dl /n "HPLJ4-RIGHTFAX"
End


Hope it works for you
Posted by: JdotQ 17 years ago
Senior Purple Belt
0
bheers,

Thank you for the reply. I neglected to mention that I am using AdminStudio 7.5 to create the transform.

Going through the process of creating a new Custom Action Wizard;

Type would be "Launch an executable"
Location -- does it matter? choices are "Stored in binary table", "Installed with the product", "Stored in the property table", "Stored in the directory table" -- I selected default of 'binary table'

(Next Window)
Source: left default of "DLLWRAP.DLL"
Target: rundll32.exe printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"

(Next Window)
Return Processing:
[X] Wait for action to finish
[_] Ignore custom action return code

In-Script Execution: (default) Immediate execution
Execution Scheduling: (default) Always schedule

--

Any recommendations/thoughts for those settings?

Also, any ideas if this be able to execute successfully by deploying the package to the computer (ex. using GPO to deploy software package -- deploying to computer rather than user)

Thanks again.
Posted by: JdotQ 17 years ago
Senior Purple Belt
0
Trying to put bheers suggestion into the package using AdminStudio, I am getting an error "Internal Error 2705. Directory". The install log has the following lines;

MSI (s) (1C:9C) [10:08:55:036]: Transforming table Directory.

MSI (s) (1C:9C) [10:08:55:036]: Note: 1: 2705 2: Directory
DEBUG: Error 2705: Invalid table: Directory; Could not be linked as tree.
MSI (c) (4C:EC) [10:08:55:051]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

Researching this a little bit I came across the following link; http://support.installshield.com/kb/view.asp?articleid=q107991

The custom action I created looks like this;

Tmp_LJ4_Inst:
Working Directory: System16Folder
Filename & Command line: [SystemFolder]rundll32.exe printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"
Return Processing: Synchronous (Ignores exit code)
In-Script Execution: Immediate Execution
Execution Scheduling: Always execute
Use 64Bit Scripting: No
Install UI Sequence: <Absent from sequence>
Install UI condition:
Install Exec Sequence: <Absent from sequence>
Install Exec Condition:
Advertise Exec Sequence: <Absent from sequence>
Advertise Exec Condition:
Admin UI Sequence: <Absent from sequence>
Admin UI Condition:
Admin Exec Sequence: <Absent from sequence>
Admin Exec Condition:
MSI Type Number 98

More details from the Directory table that I referenced the 'System16Folder'

Directory: System16Folder
Directory_Parent: TARGETDIR
DefaultDir: .:System

Directory: TARGETDIR
Directory_Parent:
DefaultDir: SourceDir


After reading http://support.installshield.com/kb/view.asp?articleid=q107991 I would think the error is because the TARGETDIR directory does not have a Directory_Parent?

I'm at a bit of loss now, I've tried several combinations but continuously end up with the same error.

Any help/ideas/suggestions??
Posted by: mazessj 17 years ago
Blue Belt
0
If you're using a working directory, it should be [SystemFolder], not [System16Folder].

rundll32.exe printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"
This command line is not quite correct. %windir% is only valid when executing from a batch file or command prompt.
In the MSI, you must replace this with the appropriate property, in this case, [WindowsFolder]. The command should be as follows:

rundll32.exe printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f [WindowsFolder]inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"

--Josh
Posted by: JdotQ 17 years ago
Senior Purple Belt
0
mazessj,

Thank you very much for the reply -- and the context switch from %windir% to [WindowsFolder].

I am able to install now, without any errors, but the Custom Action does not seem to have any effect. Here's what I did to get it to work...

Referenced;
http://support.installshield.com/kb/view.asp?articleid=Q102426

Created an entry in the Properties table for the path of the rundll32.exe;

Property: RunDLL32
Value: C:\WINDOWS\system32\

Created a Custom Action (new EXE, path in property value)

Tmp_LJ4_Inst:
Working Directory: RunDLL32
Filename & Command line: rundll32.exe printui.dll,PrintUIEntry /if /b "HPLJ4-RIGHTFAX" /f [WindowsFolder]inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 4"
Return Processing: Synchronous (Check exit code)
In-Script Execution: Immediate Execution
Execution Scheduling: Always execute
Use 64Bit Scripting: No
Install UI Sequence: <Absent from sequence>
Install UI condition:
Install Exec Sequence: <Absent from sequence>
Install Exec Condition:
Advertise Exec Sequence: <Absent from sequence>
Advertise Exec Condition:
Admin UI Sequence: <Absent from sequence>
Admin UI Condition:
Admin Exec Sequence: <Absent from sequence>
Admin Exec Condition:
MSI Type Number 50


The install runs through without any errors, but there is no printer generated from the Custom Action...

Ideas/suggestions are welcomed.
Posted by: mazessj 17 years ago
Blue Belt
0
You shouldn't need to create a property that points to a known location like the System folder. It is bad practice to set a property to a hard-coded system path like C:\WINDOWS\system32\. What if Windows is installed in C:\WINXP or C:\WINNT?

I think you're using the wrong type of custom action, type 50, which requires you to specify an EXE with a path specified by a property in the Property table. I think you want to use CA type 34*, which lets you specify an EXE file with a path referencing a directory (e.g. [SystemFolder]rundll32.exe). You should also set the Working Directory to SystemFolder.

* Wise for Windows Installer refers to CA type 34 as "Execute Program From Destination." I'm not sure what the InstallShield equivalent is, but you want the one that lets you choose a predefined Windows directory rather than a property.

--Josh
Posted by: bheers 17 years ago
Second Degree Blue Belt
0
Try stopping and starting the printspooler once the custom action is run for installing the printer.
Posted by: WisconsinPlatt 16 years ago
Senior Yellow Belt
0
Here is *a* solution to this that works for my organization.

We needed to ensure there was a PCL5 printer installed prior to RightFax being installed. I'd have liked to use the HP LJ4 drivers but XP throws up the Hardware Installation dialog box which was requiring me to try and script around it (And that kept hanging the install of the MSI when ran in the CAs) So to that end I have two CAs that install an HP LaserJet 8100 PCL printer and then deletes it after the installation is complete

ADD_PCL_PRINTER
Executable: rundll32
Command Line: printui.dll PrintUIEntry /if /f [WindowsFolder]\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 8100 Series PCL" /b "RF_PCL5Printer" /q
Synchronous (Ignore Exit Code)
Immediate Execution
Always Execute
Install UI Sequence: <Absent from Sequence>
Install Exec Sequence: After InstallValidate
Instal Exec Condition: Not Installed


REMOVE_PCL_PRINTER
Executable: rundll32
Command Line: printui.dll PrintUIEntry /dl /n "RF_PCL5Printer" /q
Synchronous (Ignore Exit Code)
Immediate Execution
Always Execute
Install UI Sequence: <Absent from Sequence>
Install Exec Sequence: After InstallFinalize
Instal Exec Condition: Not Installed

In addition I also have an MST with the following additons to the PROPERTY Table:
INSTALL_VIMPRINTER = TRUE
INSTALL_OUTLOOK = TRUE
INSTALL_FAXCTRL = TRUE
INSTALL_MAPIPRINTER = TRUE
SPROTOCOL = TCP
NPROTOCOL = TCP
PREFERREDDRIVER = 0


Hope this helps someone.
Posted by: knight 16 years ago
Orange Senior Belt
0
If the printer is still not showing up, try to reboot the machine. Event viewer could give you some information if the installation fails. Hope this helps.

knight
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ