Well, after a little more playing around, I found what I was doing wrong with FIND.I was missing the spaces that were in the file. This code seems to work now.
code:
@ECHO OFF
:START
SRVINFO >C:\RC.TXT
FIND /I " [Running] Norton AntiVirus Client" C:\RC.TXT
IF ERRORLEVEL = 1 GOTO BAD
IF ERRORLEVEL = 0 GOTO GOOD
GOTO DONE:GOOD
ECHO The Service is running
GOTO DONE
:BAD
ECHO The Service is not running
GOTO DONE
:DONE
However, I am having a problem now with the code from Jochen.
If you run the code with NAV Service running you get the correct outcome. If you stop the NAV Service you get "0" and not a blank variable or a "NotRunning" variable which you would expect. I'm not sure why this is happening.
code:
; *** Variables ***
$ChkNavService = '%comspec% /c %windir%\pv.exe -q >C:\RC.TXT'
$StopNavService = 'NET STOP "Norton AntiVirus Client"'
$StartNavService = 'NET START "Norton AntiVirus Client"'SHELL $ChkNavService
$logfile = "C:\RC.TXT"
$ = OPEN(1,$logfile,2)
IF @error = 0
$x = READLINE(1)
IF $x
DO
SELECT
CASE instr($x,"rtvscan.exe")
$CHK = "NAVNT"
CASE instr($x,"rtvscn95.exe")
$CHK = "NAV9X"
ENDSELECT
$x = READLINE(1)
UNTIL @error
ENDIF
ENDIF
$ = CLOSE (1)
SELECT
CASE $CHK = "NAVNT"
? "NAV is "$CHK
? "This should say NAVNT"
GOTO END
case $CHK = "NAV9X"
? "NAV is "$CHK
? "This should say NAV9X"
GOTO END
case 1
;unknown problem
? "NAV is "$CHK
? "This should say nothing. File entry was not found, that is why this is displaying."
GOTO END
ENDSELECT
:END
Here is what is said in the command prompt.
code:
C:\SCRIPTS>kix32 96.kixNAV is NAVNT
This should say NAVNT
C:\SCRIPTS>net stop "Norton AntiVirus Client"
The Norton AntiVirus Client service is stopping..
The Norton AntiVirus Client service was stopped successfully.
C:\SCRIPTS>kix32 96.kix
NAV is 0
This should say NAVNT
Now back to the drawing board for FIND and PV and/or maybe if someone can explain what is going wrong in the code by Jochen.
[ 02 October 2001: Message edited by: NTDOC ]