Page 1 of 2 12>
Topic Options
#162954 - 2006-06-06 09:06 PM Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Ok,
I have been trying to get my login script to run a check of the Norton antivirus version, then either install or upgrade to 10.1.0.394. On the next running of the script it should install a patch to 10.1.0.396. It works sometimes, but not always.

Here is the portion of the script that I am trying to make work:

;Norton Install and Upgrade

$NAVHome = ReadValue($RegPath+'HKLM\software\INTEL\LANDesk\VirusProtect6\CurrentVersion\', 'Home Directory')

$NavExecutable = GETFILEVERSION($NAVHome +'\vpc32.exe','ProductVersion')

Select

Case $NavExecutable < "10.1.0.394" or ""
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"

Case $NavExecutable = "10.1.0.394"
RUN "msiexec /update \\$server_name\netlogon\sav396.msp /passive /qr /norestart"


Case 1

EndSelect

? "TestNav complete..."

Sleep 2

:Norton Upgrade ends


Anyone see anything that would cause this NOT to run.

All users are accessing the script from the server (W2K). All user machines are either W2K or WXP. All users have permissions to the netlogon folder and are administrators on their local machines.

The rest of the script runs as advertised...


Thanks for any suggestions.
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162955 - 2006-06-06 10:01 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Thank anyway! As I suspected it was a simple thing that I was missing.

I had the line: $server_name=dfow2k015

and it should be $server_name = "dfow2k015"

Works like a charm now.
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162956 - 2006-06-06 10:05 PM Re: Script not running correctly!
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
What doesn't run? You do not have any logging in your "Case 1" section and therefore would not know if you ended up going that route.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#162957 - 2006-06-06 10:09 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
True enough.
I hadn't gotten to logging anything yet. But I thought it was always better to have a "Null" at the end of the select.

Any suggestions?

Thanks,
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162958 - 2006-06-07 03:10 AM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
what is $regpath?
you are looking at local setup, so that should not be there.
_________________________
!

download KiXnet

Top
#162959 - 2006-06-07 10:07 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Ok, I took out the $regpath.

Quick question about this code:

In the statement Case $NavExecutable < "10.1.0.394"

Kix interprets "10.1.0.394" as an integer, correct? Somoene looking at my script said that it may be adding all the numbers up and using that for the < argument. I say it is an integer. Who's right?

Thanks again.
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162960 - 2006-06-07 10:51 PM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nope.
if it depends what $NavExecutable holds.
it's type (as you have written it as the first part of the comparison) determines the types for the rest.
if $NavExecutable is read from registry and looks like the version string in your case statement, then, they both are strings and the comparison is a stringwise one.
_________________________
!

download KiXnet

Top
#162961 - 2006-06-07 10:55 PM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
btw, this does not work as you supposed it to:
Case $NavExecutable < "10.1.0.394" or ""

there is comparison before the or and after the or.
kixtart treats empty string same as 0 or false.
thus, your or part does nothing but adds extra strokes to your script.
what you probably try to do is:
Case $NavExecutable < "10.1.0.394" or $NavExecutable = ""
_________________________
!

download KiXnet

Top
#162962 - 2006-06-07 11:05 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Ok, I think I understand what you are saying. So, if it is treating it as a string, does the < work? It seems to, I have done some debugging and testing with other text such as:
Case $NavExecutable < "10.1.0.394" or $NavExecutable = ""
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"
? "Norton is Not Up-to-Date, Installing now. The system will reboot automatically!"
Sleep 5


Case $NavExecutable = "10.1.0.394"
RUN "msiexec /update \\$server_name\netlogon\sav396.msp /passive /qr /norestart"
? "Norton is Not Up-to-Date, Patching now..."
Sleep 4

And it seems to work fine.

However I am noticing that still quite a few machines with older versions are not updating.
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162963 - 2006-06-07 11:28 PM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well.
consider version 9 or 8.
their version strings start with larger number than the 1 that starts the version 10 string.
_________________________
!

download KiXnet

Top
#162964 - 2006-06-07 11:31 PM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
to make all older and non installed catched, use:
Case $NavExecutable < "10.1.0.394" or 10 > $NavExecutable

in the above, 10 is before the comparison (in the second part) and it thus translates the $NavExecutable in that comparison into numeric.
if it is none, it equals zero.
or if it is 10.0.121 it is translated to 10 as "." stops the translation (not a numeric char)
similarly, version 9.0.2 will translate to just 9 and 10 is more than nine.
_________________________
!

download KiXnet

Top
#162965 - 2006-06-08 02:10 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
ok, this explains some things. For instance; I currently have clients runnning 10.0.2.2000 that don't seem to be upgrading. This presents another challenge: How do I get them to be seen as less than 10.1.0.394? isn't there a way to tell Kix that the string is an integer, or to look past the "." in the string?

Thanks again for helping me understand this...
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162966 - 2006-06-08 03:49 PM Re: Script not running correctly!
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
when dealing with version numbers such as you have, I would suggest writing a UDF that split the version strings of the actual verion and the version to compare into arrays of numbers. Each array element could then be compared as numbers and you would get a valid comparisions of version numbers.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#162967 - 2006-06-08 05:22 PM Re: Script not running correctly!
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I would take all your known versions and put them into an array of strings. That way you can do simple string matches.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162968 - 2006-06-08 08:48 PM Re: Script not running correctly!
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I offer the following up for conversation...
Code:
break on

iif( CompareVersions("10.0.1.123", ">", "10.0.1.123.1"), "True", "False")


function CompareVersions($version1, $comparison, $version2, optional $split)
dim $Ver1array, $Ver2array, $Ver1arrayCnt, $Ver2arrayCnt
dim $index, $maxindex

if VarTypeName($split) <> "String" $split = "." endif

$Ver1array = split($version1, $split)
$Ver1arrayCnt = ubound ($Ver1array)

$Ver2array = split($version2, $split)
$Ver2arrayCnt = ubound ($Ver2array)

Select
case $Ver1arrayCnt <= $Ver2arrayCnt
$maxindex = $Ver2arrayCnt
redim preserve $Ver1array[$maxindex]
case $Ver1arrayCnt > $Ver2arrayCnt
$maxindex = $Ver1arrayCnt
redim preserve $Ver2array[$maxindex]
case 1
;something is wrong
EndSelect

$CompareVersions = 1
for $index = 0 to $maxindex
dim $difference

$difference = val($Ver2array[$index]) - val($Ver1array[$index])

Select
case $comparison = "="
if $version1 <> $version2
$CompareVersions = 0
$index = 1+$maxindex
endif
case $comparison = "<"
if $difference < 0 or $version1 = $version2
$CompareVersions = 0
$index = 1+$maxindex
endif
case $comparison = ">"
if $difference > 0 or $version1 = $version2
$CompareVersions = 0
$index = 1+$maxindex
endif
Endselect
next
endfunction



[updated function]


Edited by Howard Bullock (2006-06-09 01:54 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#162969 - 2006-06-08 09:18 PM Re: Script not running correctly!
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The parms with the quotes and the commas are counter-intuitive.
Otherwise, you win.

How many permutations of versions might there be in reality and given those versions, how many off the the target would need to be treated differently? I would think it could be handled with a list of known versions.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162970 - 2006-06-08 09:31 PM Re: Script not running correctly!
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Well you can view in the Symantec Console what the versions are and sort by versions, hilight those that are not at the lastest version and then export to CSV file.

Then target your KiX script to install updates on those systems.

Then your script would only need to check IF the system even has AV installed, or check if it's not set or assigned to a given Parent Server, if not then install. Which can also be done remotely from the console.

I guess what I'm saying is that except for a system that doesn't have Symantec AV or isn't reporting to your console everything for updating can be done in the console.

Top
#162971 - 2006-06-08 10:04 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Here is what i have come up with that so far is working even for older versions:

$NAVHome = ReadValue("HKLM\software\INTEL\LANDesk\VirusProtect6\CurrentVersion\", "Home Directory")

$NavExecutable = GETFILEVERSION($NAVHome +"\vpc32.exe","ProductVersion")

$ver1 = (SUBSTR($NavExecutable, 8, 1))
$ver2 = (SUBSTR($NavExecutable, 10, 1))

Select

Case $ver1 < 3
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"

Case $ver2 = 4
RUN "msiexec /update \\$server_name\netlogon\sav396.msp /passive /qr /norestart"

EndSelect


This solves the issue of listing each of the known versions, (5 on our systems) that all need to be updated, (with much less typing ). And also gives me the flexibility to easily modify these lines for other programs in the future.

Thoughts? Comments?

Tell me it's all jacked up, I can take it...
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
#162972 - 2006-06-08 10:21 PM Re: Script not running correctly!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not sure how hard it can be.
in windows world, version string is a 4-piece string.
so, checking for first, second, third and finally forth should perfectly reveal which is never.

Code:

$NAVHome = ReadValue($RegPath+'HKLM\software\INTEL\LANDesk\VirusProtect6\CurrentVersion\', 'Home Directory')
$NavExecutable = split(GETFILEVERSION($NAVHome +'\vpc32.exe','ProductVersion'),".")

if ubound($NavExecutable)<3
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"
else
if 10>$NavExecutable[0] or 1>$NavExecutable[1]
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"
else
if 0=$NavExecutable[2] and 394>$NavExecutable[3]
RUN "\\$server_name\vphome\clt-inst\win32\setup.exe /S /v/qn"
else
if 0=$NavExecutable[2] and 394=$NavExecutable[3]
RUN "msiexec /update \\$server_name\netlogon\sav396.msp /passive /qr /norestart"
endif
endif
endif
endif

_________________________
!

download KiXnet

Top
#162973 - 2006-06-08 11:09 PM Re: Script not running correctly!
ntw0rk Offline
Fresh Scripter

Registered: 2003-07-03
Posts: 15
Loc: Orlando, FL
Wow!

Ok, Now that works well! and is still fairly easily modifiable!

I will test in my environment and let you know!

Thanks very much!
_________________________
If you're not livin' on the edge, you're takin' up too much space!

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 370 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.074 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