Jump to content

Help with String manipulation

Recommended Posts


I am trying to write an automated installer for installing HP drivers for my company.

HP do supply a install manager but it is flaky and does not work 50% of the time..

The drivers are downloaded in a SPxxxxx.exe. Within this *.exe when expanded is a *.cva file (Please see attached). This file is very similar to an *.ini as it has sections to read from, and has the silent install routine switches for each driver within.

All the *.cva files have the same section, an example is shown below

[Install Execution]
SilentInstall="SP25656.exe" -s -a -silent -noreboot

So, what I am trying to acheive is the following:

1) Open each *.cva file (The amount of these files will vary based on the amount of *.cva files available for each model of PC), and look for the code quoted above.

2) Strip out the

SilentInstall= and the "" marks

So that I am left with a complete line which reads as follows:

SP25656.exe -s -a -silent -noreboot

3) And then be able to execute this command to that the driver installation is automated.

Has anyone got any ideas on how to do this please? I was thinking of reading string as quoted above into an array, but not sure how I would do this for multiple strings. Am I on the right track or not...PLEASE help??

PS: I have renamed the attachment to an txt file as I was not able to attach it to this question as a *.cva file

Link to comment
Share on other sites

Check this code too. Just like gafrost said, IniRead it does:

$sCVAFile = "SP25656.cva"
$sCLine = IniRead( $sCVAFile, "Install Execution", "SilentInstall", '')
$sArgs = StringSplit($sCLine, ' ')
$sExeFile = $sArgs[1];<-- Exe (filename)
For $i=1 To UBound( $sArgs ) - 1
    MsgBox(0, "Argument #" & $i, $sArgs[ $i ])
Link to comment
Share on other sites

But Josbe forgot to trim the "" from the exe so you have to add some more code...And I added the whole process

$sCVAFile = "SP25656.cva"
$sCLine = IniRead( $sCVAFile, "Install Execution", "SilentInstall", ""')
$sArgs = StringSplit($sCLine, ' ')
$sExeFile = $sArgs[1];<-- Exe (filename)
$sArgs[1]=StringTrimLeft($sArgs[1],1); To trim left "
$sArgs[1]=StringTrimRight($sArgs[1],1); To trim right "
For $i=1 To UBound( $sArgs ) - 1
    MsgBox(0, "Argument #" & $i, $sArgs[ $i ])
    $sCLine_stripped&=$sArgs[$i] & " ";  <--To make the $sArgs into one whole string again

IniWrite($CVAFile, "Install Execution", "SilentInstall",$sCLine_stripped); <--To store the  
final string to the .cva again

....and you are done....

Edited by hgeras
Link to comment
Share on other sites

$cvaList = fileFindFirstFile(@scriptDir & "\*.cva")
if ($cvaList > -1) then
    while (1)
        $cva = fileFindNextFile($cvaList)
        if (@error) then exitLoop

; enter code to process this CVA file,
; name of which is found in $cva


Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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