#24654 - 2002-07-09 10:29 PM
IF ELSE ENDIF PROBLEM
|
chase
Fresh Scripter
Registered: 2002-06-28
Posts: 22
|
$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?
|
Top
|
|
|
|
#24656 - 2002-07-09 10:42 PM
Re: IF ELSE ENDIF PROBLEM
|
chase
Fresh Scripter
Registered: 2002-06-28
Posts: 22
|
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!
|
Top
|
|
|
|
#24657 - 2002-07-10 03:40 PM
Re: IF ELSE ENDIF PROBLEM
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
|
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 ]
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#24658 - 2002-07-10 06:19 PM
Re: IF ELSE ENDIF PROBLEM
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
two nices tricks in this topic - counting error status with '$returncode=$returncode+...' - reducing code by using the binary OR operator thanks.
(TIP_KIX)
|
Top
|
|
|
|
#24659 - 2002-07-10 07:45 PM
Re: IF ELSE ENDIF PROBLEM
|
chase
Fresh Scripter
Registered: 2002-06-28
Posts: 22
|
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.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 329 anonymous users online.
|
|
|