Page 1 of 1 1
Topic Options
#25707 - 2002-07-23 08:05 PM ReadValue problems
Chris Beggs Offline
Fresh Scripter

Registered: 2001-09-27
Posts: 27
Loc: Kitchener
I'm having a problem with a part of my scipt.
I'm checking for a managed insatll of NAV Corp edition. I check for either of the server names otherwise I right a file and email.
All NT 4.0 machines work fine but most 2000 Pro machines will send an email although the registry key and value exist. Here is my script. Any ideas?

Chris

$AV ="$HKLM\SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion"
$AV=ReadValue ("$AV","Parent")
if $AV = Thor
goto "end"
$AV=ReadValue ("$AV","Parent")
if $AV = Tyr
goto "end"
else
open(1, "c:\2kmanage.log", 5) ; Create a temp file
writeline(1, "@FULLNAME does not have a managed Norton Installation" +chr(13) +chr(10) +chr(13) +chr(10))
writeline(1, "Workstation = @wksta" +chr(13) +chr(10))
writeline(1, "Operating System Kernel = " + $kernel +chr(13) +chr(10))
writeline(1, "Operating System = " + $system +chr(13) +chr(10))
writeline(1, "Operating System Subtype= " + $flavor +chr(13) +chr(10) +chr(10))
writeline(1, "Operating System Service Pack Level = " + $Svcpack +chr(13) +chr(10) +chr(10))
writeline(1, "Current time is @time" +chr(13) +chr(10)) ; Insert all this information in the file
close(1) ; and mail the file to me for investigation with blat.exe
shell \\freya\blat\2kmanage.bat
sleep 1
del "c:\2kmanage.log" ; clean up
cls
use y: /d
if ingroup ( "AV_Tyr" )
copy "@LDRIVE"+"\tyr\vphome\grc.dat" "c:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5"
if ingroup ( "AV_Thor" )
copy "@LDRIVE"+"\thor\vphome\grc.dat" "c:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5"
goto "end"
endif
:end
exit

Top
#25708 - 2002-07-23 08:25 PM Re: ReadValue problems
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Try it with quotes.
code:
$AV = "HKEY_LOCAL_MACHINE\SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion"
$AV=ReadValue ("$AV","Parent")
if $AV = "Thor" or if $AV = "Tyr"
goto "end"
else

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#25709 - 2002-07-23 08:31 PM Re: ReadValue problems
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Chris -

You need to match up each IF statement with an ENDIF. Try this:

code:
$AVKey="$HKLM\SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion"
$AV=ReadValue ("$AVKey","Parent")
if $AV = "Thor" or $AV ="Tyr"
; do nothing
else
open(1, "c:\2kmanage.log", 5) ; Create a temp file
writeline(1, "@FULLNAME does not have a managed Norton Installation" +chr(13) +chr(10) +chr(13) +chr(10))
writeline(1, "Workstation = @wksta" +chr(13) +chr(10))
writeline(1, "Operating System Kernel = " + $kernel +chr(13) +chr(10))
writeline(1, "Operating System = " + $system +chr(13) +chr(10))
writeline(1, "Operating System Subtype= " + $flavor +chr(13) +chr(10) +chr(10))
writeline(1, "Operating System Service Pack Level = " + $Svcpack +chr(13) +chr(10) +chr(10))
writeline(1, "Current time is @time" +chr(13) +chr(10)) ; Insert all this information in the file
close(1) ; and mail the file to me for investigation with blat.exe
shell \\freya\blat\2kmanage.bat
sleep 1
del "c:\2kmanage.log" ; clean up
cls
use y: /d
select
case ingroup ( "AV_Tyr" )
copy "@LDRIVE"+"\tyr\vphome\grc.dat" "c:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5"
case ingroup ( "AV_Thor" )
copy "@LDRIVE"+"\thor\vphome\grc.dat" "c:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5"
endselect
endif

Notice how the IF statement is supposed to work. Also, I replaced your other IF with a SELECT CASE structure. Let us know if this helps.
_________________________
Dean

Top
#25710 - 2002-07-23 08:38 PM Re: ReadValue problems
Sealeopard Offline
KiX Master
*****

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

There's an IF too much in the IF line in your code. It has to be
code:
if $AV = "Thor" or $AV = "Tyr"

Secondly, the copy to the 'All Users' profile will only work with the correct permissiosn, by default only 'Local Administrators' can write to that area.

[ 23 July 2002, 20:40: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#25711 - 2002-07-23 08:40 PM Re: ReadValue problems
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Right you are [Embarrassed] [Embarrassed] [Embarrassed]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#25712 - 2002-07-23 08:45 PM Re: ReadValue problems
Chris Beggs Offline
Fresh Scripter

Registered: 2001-09-27
Posts: 27
Loc: Kitchener
Thanks for the help it works great now!!
This forum really is the best.
Everytime I've asked a question the answer is there in minutes.

I've changed the other IF statements to select statements as well.

Are select statements better than IF or does it matter?

Chris

Top
#25713 - 2002-07-23 08:56 PM Re: ReadValue problems
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Jens and Les,

WRONG you are... [Roll Eyes]

Generally speaking that folder area is not accessable for Everyone, but the last folder 7.5 has EVERYONE FULL rights by design from Symantec.

Here is some sample code for ideas as well.

code:
; *** File Name:     NAVPARNT.KIX *** v1.6
; *** Date Created: 09-19-2001 1:06 am PST - By Ron Lewis
; *** Comments: Reassigns the NAV Parent Server based on IP Address
; *** NOTE: Code may need to be modified to include actions when valid IP is not known.

; *** Variables ***
$crlf = chr(13)+chr(10) ;chr(13) is a Carriage Return and chr(10) is a line feed
$NavHomeDir = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion","Home Directory")
$DataLocation = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Common AppData")
$PARENT = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Intel\LANDesk\VirusProtect6\CurrentVersion","Parent")
$NoNavWarn = EXISTKEY("HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\Quarantine")
$CleanGRCx = 'attrib -r "$NavHomeDir\GRC.DAT"'
$CleanGRCy = 'attrib -r "$DataLocation\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT"'

IF @INWIN = 1
$SRVR = ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
IF $SRVR<>"WinNT" ; System is not a Workstation so assume it is a Server
RETURN
ENDIF
ENDIF
IF $NoNavWarn <> 0
$nul = MESSAGEBOX("Unable to locate the Norton AntiVirus program on this system. Please contact the Helpdesk to have the program installed or checked for problems with a previous installation.", "Norton AntiVirus Program Update", 16)
GOTO END
ENDIF

IF EXIST($NavHomeDir+"\GRC.DAT")
SHELL $CleanGRCx
DEL ($NavHomeDir+"\GRC.DAT")
ENDIF
IF EXIST("$DataLocation\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT")
SHELL $CleanGRCy
DEL ("$DataLocation\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT")
ENDIF

SELECT
CASE (SUBSTR(@IPADDRESS0,1,11)) = "122.100.243" AND $PARENT = "SERVER01"
GOTO END
CASE (SUBSTR(@IPADDRESS0,1,11)) = "123. 26.110" AND $PARENT = "SERVER02"
GOTO END
; ETC....
ENDSELECT

SELECT
CASE (SUBSTR(@IPADDRESS0,1,11)) = "122.100.243"
$NavParent = "SERVER01"
CASE (SUBSTR(@IPADDRESS0,1,11)) = "123. 26.110"
$NavParent = "SERVER02"
; CASE ETC....
CASE 1
$NavParent = "SERVER01"
ENDSELECT
$GrcUpdateNew = '%comspec% /c copy "\\$NavParent\vphome\grc.dat" "$DataLocation\Symantec\Norton AntiVirus Corporate Edition\7.5\GRC.DAT" >nul'
$GrcUpdateOld = '%comspec% /c copy "\\$NavParent\vphome\grc.dat" "$NavHomeDir" >nul'

IF @INWIN = 1
GOTO NTWIN
ELSE
GOTO WINX
ENDIF
GOTO END

:NTWIN
IF (Exist($DataLocation+"\Symantec\Norton AntiVirus Corporate Edition\7.5\nul") = 1)
$nul = MESSAGEBOX("Please wait... Norton AntiVirus Definitions are being updated on your system...", "Norton AntiVirus Program Update", 64, 10)
SHELL $GrcUpdateNew
SHELL '%comspec% /c NET STOP "Norton AntiVirus Client" >NUL'
SHELL '%comspec% /c NET START "Norton AntiVirus Client" >NUL'
GOTO END
ELSE
$nul = MESSAGEBOX("Please wait... Norton AntiVirus Definitions are being updated on your system...", "Norton AntiVirus Program Update", 64, 10)
SHELL $GrcUpdateOld
SHELL '%comspec% /c NET STOP "Norton AntiVirus Client" >NUL'
SHELL '%comspec% /c NET START "Norton AntiVirus Client" >NUL'
GOTO END
ENDIF
GOTO END

:WINX
SHELL $GrcUpdateOld
$nul = MESSAGEBOX("Notice: Norton AntiVirus Definitions were updated on your system. Please restart your computer to complete the Norton AntiVirus update once the logon script and any other applications have finished loading.", "Norton AntiVirus Program Update", 64)
GOTO END

:END
RETURN


Top
#25714 - 2002-07-23 08:58 PM Re: ReadValue problems
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the difference is in the concept.
in select you execute just the first matching case.
in if the same can take up multiple if else if...
then, if you need to get all the matches, if is simpler and shorter to code.
_________________________
!

download KiXnet

Top
#25715 - 2002-07-23 09:40 PM Re: ReadValue problems
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, I'll confess... I just skimmed the code and posted (hastily) the first thing I noticed.

I mistakenly left in that second IF. I didn't look at the perms issue.

Upon closer scrutiny, the following line is also wrong.
copy "@LDRIVE"+"\tyr\vphome\grc.dat" "c:\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5"

You see, @LDrive expands to \\Server\ so once expanded there would be two hacks after the server name.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#25716 - 2002-07-23 10:25 PM Re: ReadValue problems
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Don't have NAV CE, so didn't know that. Thanks!
_________________________
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 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.053 seconds in which 0.025 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