Jump to content

Variable replacer


Recommended Posts

Who has never had problems with some

.ini configuration files,

.iss install descriptions or

.reg registry addons,

containing absolute directories?

I have...

And I do hate having absolute directories on my Install-CD/DVD

C:\Program Files\... :realmad:

Because with these, you're limited to installing on the C-drive only...

I like to keep the possiblity to do installations on other partitions as wel...

So I looked for a solution... B)

And found one :P

OK, let me start by saying that I found it, I didn't create it...

' Subject: Perform Search and Replace on a file

' Author: Brad Thurber - brad.thurber--AT--home.com

' Credit: Mostly a cut-and-paste from other helpful people

' Date: Sept 13, 1999

' Version: 0.11

So I don't deserve credit for this program, but I altered it a little for easier and silent use. :D

I know how scripts work, I can read them, I can change them, but I still can't make my own...

I just have something with putting pieces together, I guess.

It's just a little .vbs script.

But it works like magic...

Replace.rar

How to use:

Replace.vbs can now simply be called from a batch-file with:

Replace.vbs <FILENAME> <FINDSTRING> <REPLACESTRING>

Example:

The Freeware-program 'FileRecovery' ( http://www.pcinspector.de/file_recovery/nl/welcome.htm )

can be installed with setup.exe -s -a -s -f1"/<directory>/setup.iss"

setup.iss can be obtained by installing 'Filerecovery with setup.exe -R

My testsystem is on de G-drive, this is how my setup.iss looked like:

[InstallShield Silent]
Version=v7.00
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-DlgOrder]
Dlg0={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdWelcome-0
Count=6
Dlg1={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdLicense-0
Dlg2={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdRegisterUser-0
Dlg3={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdAskDestPath-0
Dlg4={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdStartCopy-0
Dlg5={0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdFinish-0
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdWelcome-0]
Result=1
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdLicense-0]
Result=1
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdRegisterUser-0]
szName=FileInspector
szCompany=-My Company-
Result=1
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdAskDestPath-0]
szDir=G:\Program Files\PC Inspector File Recovery
Result=1
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdStartCopy-0]
Result=1
[Application]
Name=PC Inspector File Recovery
Version=4.0
Company=Convar Deutschland GmbH
Lang=0009
[{0DD140D3-9563-481E-AA75-BA457CBDAEF2}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0

Now the problem with this, is the line:

szDir=G:\Program Files\PC Inspector File Recovery

Installations on C, D, E just won't work with this line...

More specific, G:\Program Files can be a big problem.

In batch-files, just replacing this with %ProgramFiles% will do,

but the same solution doesn't work with most configuration-files.

There's no simple way to change it to make it usable on all partition-installs.

Now with Replace.vbs, there is a solution...

Replace.vbs can make the right changes to make it work...

However, these changes can't happen on a CD, the file needs to be copied to Hardisk first.

So, this is how it can be done:

1. Copy the file to be changed to %temp%

2. Use Replace.vbs on the file in %temp% to make the changes

3. Use the file in %temp% for the installation

Example: (I called this one Prepare.cmd)

cd /d %0\..@echo off
cmdow @ /HID
@echo off

copy /y setup.iss "%temp%\setup.iss"

Replace.vbs "%temp%\setup.iss" "G:\Program Files" "%ProgramFiles%"

EXIT

This works like a charm...

First it copies setup.iss tot %temp%,

then all G:\Program Files will be changed to %ProgramFiles%

The real magic about this is, that %ProgramFiles% won't be written to the file...

No, no, no,... the real (absolute) path will be written to it!!!!

How much better can it be?

Then to finnish the installation, all there's left to do is point the installer (still on the CD) to setup.iss in the %temp%-directory.

Like this:

pci_filerecovery.exe -s -a -s -f1"%temp%\setup.iss"

Enjoy... :hello:

Edited by Evolver
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...