Page 1 of 1 1
Topic Options
#24654 - 2002-07-09 10:29 PM IF ELSE ENDIF PROBLEM
chase Offline
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
#24655 - 2002-07-09 10:33 PM Re: IF ELSE ENDIF PROBLEM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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,
_________________________
!

download KiXnet

Top
#24656 - 2002-07-09 10:42 PM Re: IF ELSE ENDIF PROBLEM
chase Offline
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 Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
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 Offline
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)
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#24659 - 2002-07-10 07:45 PM Re: IF ELSE ENDIF PROBLEM
chase Offline
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. [Cool]

Top
#24660 - 2002-07-10 07:53 PM Re: IF ELSE ENDIF PROBLEM
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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.
_________________________
There are two types of vessels, submarines and targets.

Top
#24661 - 2002-07-10 07:55 PM Re: IF ELSE ENDIF PROBLEM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, think that program which installs itself in startup folder does not use registry.
_________________________
!

download KiXnet

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 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.054 seconds in which 0.023 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