Jump to content

Vexatious HP Driver Install (and simple command line question)


Recommended Posts

I am trying to automate a pre-install of the HP driver and software for the OfficeJet 4630 ( OJ4630_198.exe ) with a simple AutoIt script since HP doesn't offer a full-featured corporate install package.  The script is quite simple and works until a point:

Run("OJ4630_198.exe","")
WinWaitActive("HP Officejet 4630 series")
ControlClick("HP Officejet 4630 series","","[ID:1189]")
WinWaitActive("HP Officejet 4630 series")
ControlClick("HP Officejet 4630 series","","[ID:1099]")
ControlClick("HP Officejet 4630 series","","[ID:1100]")
ControlClick("HP Officejet 4630 series","","[ID:1104]")
ControlClick("HP Officejet 4630 series","","[ID:1103]")
ControlClick("HP Officejet 4630 series","","[ID:1016]")
WinWaitActive("HP Officejet 4630 series")
ControlClick("HP Officejet 4630 series","","[ID:1112]")
ControlClick("HP Officejet 4630 series","","[ID:1016]")
WinWaitActive("[TITLE:HP Officejet 4630 series; INSTANCE:2]", "")
ControlClick("HP Officejet 4630 series","","[ID:11003]")
ControlClick("HP Officejet 4630 series","","[ID:1]")
WinWaitActive("HP Officejet 4630 series")
ControlClick("HP Officejet 4630 series","","[ID:1]")

After the line ControlClick("HP Officejet 4630 series","","[ID:1016]") the script would simply stop.  After this line executes is when the driver and two software packages are actually installed causing the window to eventually close and reopen. Because of this, I kept checking the Windows ID tag to see if it changed and it only changed after the install of all three packages so I added an INSTANCE to the next ControlClick line and set the INSTANCE to 2.  Still doesn't work.  I then tried changing the INSTANCE from 1 to 5 and none of them worked.  At this point, I'm not sure what's going on.  Anyone know what's happening and how to fix it?

================================================================================================

As an aside, I'm pretty new to AutoIt and was wondering how to declare the current folder as the root in a command line much like one would use %~dp0 in a batch.  I would like to place the script in a root folder and then place the driver file in the subfolder <folder that script is in>\resources\driver\hp\4630.  In a batch, the command line would be:

start "" /wait %~dp0resources\driver\hp\4630\OJ4630_198.exe

What would be the AutoIt equivalent?

================================================================================================

Finally, in the forum's Example Scripts section I tried to post two scripts I had created and found useful but I couldn't post anything there.  Is there a posting limit one must reach in order to post there?

Thanks for any help!

-bdwilcox

Link to comment
Share on other sites

hey bdwilcox,

             I would try putting a sleep command after the line in question.  For how ever long it is taking to install the packages.

Sleep (3000) ; This pauses the script for 3 seconds.

It has worked for me but than again I am fairly new to AutoIt too.

Link to comment
Share on other sites

Oh, man, that is tempting but I need to resist making this any more kludgy than it already is.  "Sleeping" is such a dangerous panacea; it's so simple and "usually" works but so many factors can make it fail.  I try to avoid it like the plague.

Link to comment
Share on other sites

Usually there is some text that is exclusive to the window you are waiting for so you can do a WinWait("Title", "Text") instead of using instance or sleep.

 

As for how to use the current directory with autoit most of the time you can use @ScriptDir assuming  your trying to call resources from the same folder as the script.

Take a look at the Macros help page, lots of useful things in there. 

Link to comment
Share on other sites

  • Moderators

@bdwilcox this driver has an MSI for both x86 and x64. Why not use that and just make a silent install?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

To xcaliber13, thank you for the suggestion but understand that I've had bad experiences with scripts that depended on timed wait states in the past.  I appreciate your attempt to help, though, so please don't be offended.  I tried what you suggested and it worked but I'm always concerned that external forces can cause a script to fail and do whatever I can to harden the script.

To JLogan3o13, I'm not sure how to do a custom silent install using the driver's MSI's.  The setup needs to install not only the printer driver itself but also the software to go along with it (HP Scan, printer help file, IRIS OCR agent) while excluding other software from the default install (HP survey, driver update agent, etc.).  Do you know how to customize and automate this for an HP driver package by using its MSI in a silent install?

To ViciousXUSMC, thank you for the commands and syntax as those were the ones I needed.  Here is the completed script for the HP OfficeJet 4630 driver OJ4630_198.exe pre-install that only installs the IRIS OCR agent and printer help file from the optional install components (in case it might help someone):

;Runs an executable by treating the script's directory as the root directory
Run(@scriptdir & "\Resources\Programs\HP Drivers\OJ4630_198.exe","")
WinWaitActive("HP Officejet 4630 series", "Your printer is prepared if it's turned on, ink is installed, and paper is loaded.")
ControlClick("HP Officejet 4630 series","","[ID:1189]")
WinWaitActive("HP Officejet 4630 series", "Get the software recommended by HP to complete your printing experience.")
ControlClick("HP Officejet 4630 series","","[ID:1099]")
ControlClick("HP Officejet 4630 series","","[ID:1100]")
ControlClick("HP Officejet 4630 series","","[ID:1104]")
ControlClick("HP Officejet 4630 series","","[ID:1103]")
ControlClick("HP Officejet 4630 series","","[ID:1016]")
WinWaitActive("HP Officejet 4630 series", "Please review the following installation agreements and settings.")
ControlClick("HP Officejet 4630 series","","[ID:1112]")
ControlClick("HP Officejet 4630 series","","[ID:1016]")
WinWaitActive("HP Officejet 4630 series", "Connect later – Do not connect to the printer now. I will connect it later.")
ControlClick("HP Officejet 4630 series","","[ID:11003]")
ControlClick("HP Officejet 4630 series","","[ID:1]")
WinWaitActive("HP Officejet 4630 series", "The software has been installed successfully.  However, your new HP printer has not yet been connected to this computer.")
ControlClick("HP Officejet 4630 series","","[ID:1]")

 

Link to comment
Share on other sites

1 hour ago, bdwilcox said:

how to do a custom silent install using the driver's MSI's

there are plenty of freeware utilities that allow you to either edit the MSI or create an MST for it. if robustness is your primary consideration, then working with MSI/MST should be your direction.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Finally, does anyone know how to click on text in a Window if it matches a text string I tell it beforehand in the script?  The problem I'm facing: during an HP driver install, it lists all of the printers of that type it finds on the network.  You are supposed to click the printer instance you want to install (which selects and highlights its line in the list) and then click the Next button, but since I'm not sure what printers it will list in what order, I want it to select the line if it finds a unique text string on that line (in this case, the printer's MAC address that I declare somewhere in the script).

The bigger problem is that when I use the  AutoIt Window Info program to examine that printer line, it doesn't see each printer line as a unique control but instead sees the entire list block of all found printers as one control; therefore I will need it to click on the unique text itself to select the line its on since Windows Info doesn't see it's line as a unique control with its own ID (screenshot attached).

HP Officejet Pro 8600 Illustrated.jpg

If that's not possible, is there any way to make the script pause, wait for the user to select the desired printer line and then hit the Next button before it continues?

Edited by bdwilcox
Link to comment
Share on other sites

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

OK, downloaded a number of MSI packagers like Advanced Installer, Smart Packager, AppDeploy Repackager and ORCA and this is way over my head.  I don't even know where to start with these things.  HP driver packages are byzantine enough and these packagers are asking all kinds of questions about what files are x86 and x64...  The original HP installer is for both and I usually just let it determine what to install but these packagers seem to want to differentiate on the file level and quite frankly I have no idea what to feed them.

On another note, looked at the ControlListView command and don't see a clear way to use it in my case.  It's almost like I need nested ControlListView commands to feed the result of the FindItem control to the Select control like so:

ControlListView ( "HP Officejet Pro 8600", "", 2001, "Select", ControlListView ( "HP Officejet Pro 8600", "", 2001, "FindItem", "8851FB150E26",3))

Tried this in my script and it didn't work...and it crashed the HP installer.  :(

I really found the documentation page for this command lacking.  So:

1) What does the last field in FindItem declare as it isn't documented well?  The documentation says SubItem, which the documentation also declares to be a column value, so does this allow you to tell the FindItem control to only look in a certain column in the table (Here i put a 3 as I want it to look in column 3, the MAC address column)?

2) For the Select control it has two parameters called From and To; are these numerical markers for the table grid or are they text strings?  How do I declare what item for Select to, um, select?

Just a little lost on the syntax here as the documentation is a bit...vague.

 

 

Edited by bdwilcox
Link to comment
Share on other sites

  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...