chase
(Fresh Scripter)
2002-07-09 10:29 PM
IF ELSE ENDIF PROBLEM

$returncode = EXIST ("C:\Documents and Settings\All Users.winnt\Start Menu\Programs\Startup\ifagent.exe")
$returncode = EXIST ("C:\Windows\start menu\programS\startup\ifagent.exe")
If $returncode=0
RUN \\INTS1\INSTALL\IFAGENT\IFAGENT.EXE EXIT
ELSE
EXIT
ENDIF

If the file is present (return code of 1) I still get a message that the ifagent was installed. I only want to execute the install when the file is not present (return code of 0). I get the install regardless of my return code. Why?


LonkeroAdministrator
(KiX Master Guru)
2002-07-09 10:33 PM
Re: IF ELSE ENDIF PROBLEM

easy.
it probably is in the first location.
and not second.
so you erase it the returncode with your second line.
that simple.
change the second line to:
$returncode = $returncode + EXIST ("C:\Windows\start menu\programS\startup\ifagent.exe")

cheers,


chase
(Fresh Scripter)
2002-07-09 10:42 PM
Re: IF ELSE ENDIF PROBLEM

That did it. I see what you mean now. It looked at the second line and did not find present so executed the install based on teh second return code of "0".

Thanks!


Sealeopard
(KiX Master)
2002-07-10 03:40 PM
Re: IF ELSE ENDIF PROBLEM

code:
$returncode = EXIST ("%ALLUSERPROFILE%\Start Menu\Programs\Startup\ifagent.exe") | EXIST ("C:\Windows\start menu\programs\Startup\ifagent.exe")
If $returncode=0
RUN \\INTS1\INSTALL\IFAGENT\IFAGENT.EXE EXIT
ELSE
EXIT
ENDIF

would give you a return code of '1' if either of those files exist. If you use the '+' operator, you might end up with a return code of '2'. I know, just a minor thing, but it shows how to use the binary or operator '|' which would be appropriate for this type of problem.

One question though, why is there an executable in the START menu, nromally one puts only the links to executables into the folder. Thus, you would have to check for an .LNK file.

[ 10 July 2002, 15:42: Message edited by: sealeopard ]


MCA
(KiX Supporter)
2002-07-10 06:19 PM
Re: IF ELSE ENDIF PROBLEM

Dear,

two nices tricks in this topic
- counting error status with '$returncode=$returncode+...'
- reducing code by using the binary OR operator
thanks.

(TIP_KIX)


chase
(Fresh Scripter)
2002-07-10 07:45 PM
Re: IF ELSE ENDIF PROBLEM

What I am trying to do with this script is see if the ifagent is installed. If it is it will be in the startup on the local pc. If it exist, do nothing. If it does not exist, go install it.

Hey thanks for the binary or operator. That tidies things up nicely. [Cool]


Sealeopard
(KiX Master)
2002-07-10 07:53 PM
Re: IF ELSE ENDIF PROBLEM

Why don't you check approrpiate registry keys for the existance of IfAgent? Look for example in KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall or the programs registry.

LonkeroAdministrator
(KiX Master Guru)
2002-07-10 07:55 PM
Re: IF ELSE ENDIF PROBLEM

jens, think that program which installs itself in startup folder does not use registry.