Page 1 of 1 1
Topic Options
#129913 - 2004-11-19 04:23 PM Split???
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
can someone tell if i'm going in the right direction.
here's my script:
$check=ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings","MinorVersion")
If $check=("Q811383")
"YES IT WORKS"
else
"IT DON'T WORK"
ENDIF

now i know this don't work & the string returned has more entries i.e. ";SP1;Q811383;"

i need to know how to check if the string 'contains' "Q811383"

I'm thinking using SPLIT() specifying ";" as the delimiter to grab a substring.

Is this the best/easiest method to use?

The "MinorVersion" could vary on any of the PC's running the script so i don't have a set string i can split (if yeah know what a mean)
cheers

Top
#129914 - 2004-11-19 04:45 PM Re: Split???
Anonymous
Unregistered


ok, i can get it to work using:
$check=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings","MinorVersion")
$array=Split($check,';')[2]
for each $element in $array
$element ?
next
If $array=("Q811383")
"YES IT WORKS"
else
"IT DON'T WORK"
ENDIF
----------
BUT, like i said the "Q811383" might not be the [2] on all the PC's. Anyway i can get it to search through all substrings?

getting warmer

Top
#129915 - 2004-11-19 04:48 PM Re: Split???
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
you are half way there... use split() and ascan() toghther!

Code:

if ascan(split($check,";"),"Q811383")+1
;yes it works
else
;no...
endif



also... you could just instr()

Code:

if instr($check,"Q811383")
;yes....
else
;no...
endif



Bryce

Top
#129916 - 2004-11-19 04:52 PM Re: Split???
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
did i tell you i luv ya
cheers boss, you da man!
horraaa

Top
#129917 - 2004-11-19 07:20 PM Re: Split???
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What is your reasoning to force precedence using parens in this line?

If $array=("Q811383")
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129918 - 2004-11-19 10:35 PM Re: Split???
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think that INSTR() would be a better choice and more efficient to see if a string was contained within a larger string.

Edited by Howard Bullock (2004-11-20 05:57 AM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#129919 - 2004-11-20 01:11 AM Re: Split???
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Code:

if instr($check,"Q811383;")


will prevent potential false-positives.
_________________________
There are two types of vessels, submarines and targets.

Top
#129920 - 2004-11-22 10:44 AM Re: Split???
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Code:

if instr($check,"Q811383;")


will prevent potential false-positives.




Better would be:
Code:
if instr(";"+$check+";",";Q811383;")


Top
#129921 - 2004-11-22 11:02 AM Re: Split???
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
yeah guys your right. i did come across a minor problem with the file names, it wasn't being too acurate. cheers for the help, works better now. Should i do the same for the SP1 search:

;Read IE patches installed
$check=ReadValue("HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings","MinorVersion")
;split string to substrings
$array=Split($check,';')
for each $element in $array
$element ?
next
;if patch exists then do nothing
if instr(";"+$check+";",";Q811383;")
GOTO "end"
else
;install patch if SP1 is installed - REQUIRED
if instr($check,"SP1")
RUN "@LDRIVE\q811383 /Q"
ENDIF
ENDIF
:end

I also need something to check the file version of a DLL file. I tried GetFileVersion but then read that it only works with EXE files. Is there anything that can get the BinFileVersion of a DLL? (or should i start a new thread for that?)

Top
#129922 - 2004-11-22 11:35 AM Re: Split???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
your code uses goto and is bloated anyways...
take a lookie of this.
same stuff accomplished, just a tiny little shorter, sorta...
Code:

if -1=ascan(Split(ReadValue("HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings","MinorVersion"),';'),"Q811383") and instr($check,"SP1")
RUN @LDRIVE+"q811383 /Q"
ENDIF



oh...
getfileversion supports bin-info...
you just need 4.22 (iirc) version of kix.
_________________________
!

download KiXnet

Top
#129923 - 2004-11-22 11:59 AM Re: Split???
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You can also check the "uninstall" registry key directly for patch installs, for example:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Q811383

Top
#129924 - 2004-11-22 12:54 PM Re: Split???
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
well, as usual you guys demonstrate how it's really done.
i thank y'all for your help (even if it reminds me how poor my logic is )


Top
#129925 - 2004-11-22 12:56 PM Re: Split???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
not sure should I say poor.
I would say, you make it more complex in your mind than it really is.
_________________________
!

download KiXnet

Top
#129926 - 2004-11-22 01:21 PM Re: Split???
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland

story of my life mate

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 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.063 seconds in which 0.024 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