Page 1 of 1 1
Topic Options
#176608 - 2007-05-30 10:43 PM if exist ($key) and if exist ($key)
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
Is it possible to do several if exist statements during a function .

For example i want to check if laptop and if you have a VPN client installed. Is this possibel to do?? look at ; Done
If $IsLaptop AND If Exist($path) in script

 Code:
;*************************************************************************************************************************
; Connect to computer's WMI service
$objWMIService = GetObject( "winmgmts://./root/cimv2" )
; Display error number and description if applicable
If @ERROR
	ShowError()
EndIf

; Get chassis object
$colChassis = $objWMIService.ExecQuery( "Select * from Win32_SystemEnclosure", , 16 )
; Display error number and description if applicable
If @ERROR
	ShowError()
EndIf


; Remove statements if you want to check for more specific
; laptop type (see comment lines after each CASE statement)
For Each $objChassis in $colChassis
	For Each $objItem in $objChassis.ChassisTypes
		Select
			Case $ObjItem =  8
				; Portable
				$IsLaptop = 1
			Case $ObjItem =  9
				; Laptop
				$IsLaptop = 1
			Case $ObjItem = 10
				; Notebook
				$IsLaptop = 1
			Case $ObjItem = 11
				; Hand Held
				$IsLaptop = 1
			Case $ObjItem = 12
				; Docking Station
				$IsLaptop = 1
			Case $ObjItem = 14
				; Sub Notebook
				$IsLaptop = 1
			Case 1
				$IsLaptop = 0
		EndSelect
	Next
Next

; Done
If $IsLaptop AND If Exist($path)
	?"This computer is a laptop ..........checking xxxx Security Settings "
	Goto InstallClient	
EndIf
Else
	?"This computer is NOT a laptop no additonal settings required"
EndIf

; Return code
Quit $IsLaptop


Function ShowError()
	? "Error # @ERROR"
	?
	Syntax
EndFunction


Function Syntax()
	? "IsLaptop.kix,  Version 1.00"
	? "Check if a computer is a laptop"
	?
	? "Usage   :  KIX32  ISLAPTOP.KIX  [ $$help=1 ]"
	?
	? "Returns :  Errorlevel 2 after help screen, 1 on laptops, otherwise 0"
	?
	; Abort with return code 1
	Quit 2
EndFunction


Top
#176612 - 2007-05-31 01:04 AM Re: if exist ($key) and if exist ($key) [Re: estrada]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes but do not repeat the IF.
If $IsLaptop AND Exist($path)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176615 - 2007-05-31 09:21 AM Re: if exist ($key) and if exist ($key) [Re: estrada]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
this is gonna work:
 Code:
If $IsLaptop AND If Exist($path)
	?"This computer is a laptop ..........checking xxxx Security Settings "
	Goto InstallClient	
EndIf
Else
	?"This computer is NOT a laptop no additonal settings required"
EndIf

Remove the first EndIf.

Top
#176620 - 2007-05-31 04:00 PM Re: if exist ($key) and if exist ($key) [Re: Arend_]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
i get the following error when i add the line If $IsLaptop AND If Exist($path)
:
ERROR : Error in expression.!

Top
#176622 - 2007-05-31 04:06 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You need to remove the second If just before the And just like Less already said.

Edited by Mart (2007-05-31 04:07 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176629 - 2007-05-31 06:11 PM Re: if exist ($key) and if exist ($key) [Re: Mart]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
it is removed...

; Done
If $IsLaptop And If Exist($path)
?"This computer is a laptop ..........checking xxx Security Settings "
Goto xxcclient
Else
?"This computer is NOT a laptop no additonal settings required"
EndIf

Top
#176630 - 2007-05-31 07:17 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, you prefer apronk's advice over mine.
How's that working for you?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176632 - 2007-05-31 07:34 PM Re: if exist ($key) and if exist ($key) [Re: Les]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
alright Les so once more what do i include or exclude...:

;Done
If $IsLaptop And Exist($path)
?"This computer is a laptop ..........checking xxx Security Settings "
Goto xxcclient
Else
?"This computer is NOT a laptop no additonal settings required"
EndIf


Edited by estrada (2007-05-31 07:39 PM)

Top
#176637 - 2007-05-31 08:24 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
Got it working ..thanks LES---
Top
#176657 - 2007-05-31 11:46 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
 Code:
If $IsLaptop And Exist ($path)
  ? "This computer is a laptop ..........checking xxx Security Settings "
Else
  ? "This computer is NOT a laptop no additonal settings required"
EndIf


It is considered a better practice to not use the GOTO statements. If you need further assistance with writing the code to eliminate the GOTO please let us know.

Top
#176682 - 2007-06-01 04:39 PM Re: if exist ($key) and if exist ($key) [Re: NTDOC]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
OK another quick question.

How can i log which machines have this software and those machines which run the softwrae install?? Is this somewhat how...

;Prepare logfile
$Log = $Server + "\netlogon\logon.log"
$DeLim = ","
$Chr = Chr(13) + Chr(10)

Top
#176684 - 2007-06-01 05:05 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I wrote a FAQ on that. There are several options but an INI file is probably the best.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176686 - 2007-06-01 05:21 PM Re: if exist ($key) and if exist ($key) [Re: Les]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I agree, that way you can use the ini to shutdown all computers at night too.
Top
#176689 - 2007-06-01 09:17 PM Re: if exist ($key) and if exist ($key) [Re: Arend_]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
so les where can i read up on how to accomplish this.....
Top
#176690 - 2007-06-01 10:38 PM Re: if exist ($key) and if exist ($key) [Re: estrada]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The FAQ forum.
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=5

The aforementioned FAQ.
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81930&page=3#Post81930
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.07 seconds in which 0.028 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