Page 1 of 1 1
Topic Options
#36706 - 2003-02-20 08:39 AM Adding a switch to the middle of a string
Anonymous
Unregistered


I am trying to write a script that will auto uninstall Dr Sol's VirusScan 4.0.3.

I can read the uninstall string from the registry but I wish to amend it as follows

typical uninstall string

C:\WINNT\ISUNINST.EXE '*' C:\PROGRA~1\Citrix\ICACLI~1\Uninst.isu

I need to add some switches where I have but a '*'

I've looked at the trim/len/substr commands, but can't use them as the uninstall string varies, so the length can't be specified.

is there a way to break the string at the first space add a switch or two and add the rest of the original string ?

Many thanks in advance

Damon

Top
#36707 - 2003-02-20 08:44 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Damon,

If I got that correctly (Only one pot of Coffee this morning so far)

you could do that like :



break on

$string = "C:\WINNT\ISUNINST.EXE '*' C:\PROGRA~1\Citrix\ICACLI~1\Uninst.isu"

$switches = " /i /x /n '*' "

$uString = join(split($string,"'*'"),$switches)

$ustring ?

get $



hth
Jochen
_________________________



Top
#36708 - 2003-02-20 08:46 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh yeah ... if the switches shall replace the '*'

simply do that :



break on

$string = "C:\WINNT\ISUNINST.EXE '*' C:\PROGRA~1\Citrix\ICACLI~1\Uninst.isu"

$switches = "/i /x /n"

$uString = join(split($string,"'*'"),$switches)

$ustring ?

get $

_________________________



Top
#36709 - 2003-02-20 08:47 AM Re: Adding a switch to the middle of a string
Anonymous
Unregistered


Morning Jpols,

Can you use a space as a delimiter, when you use split ?

Top
#36710 - 2003-02-20 08:49 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
yeah ,

but that would split the string into an array on every occurance of Whitespace ...

Try the second example (Much better I thinK)
_________________________



Top
#36711 - 2003-02-20 08:49 AM Re: Adding a switch to the middle of a string
Anonymous
Unregistered


ahh... just finished reading the help file... I'm sure this will work...

Thank You Jpols

Top
#36712 - 2003-02-20 08:52 AM Re: Adding a switch to the middle of a string
Anonymous
Unregistered


the '*' doesn't actually appear in the uninstall string, I put it there to show where I need to add the switch. apologies if I misled you

fingers crossed that there is only one space

Top
#36713 - 2003-02-20 08:53 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Damon ... Then I think the second sample I posted will fit perfectly [Big Grin]
_________________________



Top
#36714 - 2003-02-20 08:54 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh NO !

Now I woke up ... the '*' was only a placeholder you added to make the position clear ...
Wait, need to recode [Roll Eyes]
_________________________



Top
#36715 - 2003-02-20 08:57 AM Re: Adding a switch to the middle of a string
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

If it is 100% sure that the whitespace between the executable and the path is the ONLY one you could do this :



break on

$string = "C:\WINNT\ISUNINST.EXE C:\PROGRA~1\Citrix\ICACLI~1\Uninst.isu"

$switches = " /i /x /n "

$uString = join(split($string," "),$switches)

$ustring ?

get $



Now ?

J.

[ 20. February 2003, 08:58: Message edited by: jpols ]
_________________________



Top
#36716 - 2003-02-20 09:02 AM Re: Adding a switch to the middle of a string
Anonymous
Unregistered


Many thanks.. I'll let you know if all is well
Top
#36717 - 2003-02-20 05:04 PM Re: Adding a switch to the middle of a string
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Alternatively, there's alwasy INSTR and INSTRREV to find specific locations inside a string. E.g.
code:
$a='C:\WINNT\ISUNINST.EXE '*' C:\PROGRA~1\Citrix\ICACLI~1\Uninst.isu'

$b=left($a,instr($a,'.exe')+4)
$c=substr($a,instr($a,'.exe')+5)

_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 823 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.137 seconds in which 0.068 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org