Page 2 of 2 <12
Topic Options
#76783 - 2003-09-23 12:37 AM Re: keyexist()
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
PCMCIA and Battery are not always good reliable detection for a Laptop vs. Desktop.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#76784 - 2003-09-23 12:37 AM Re: keyexist()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kinda.
but that is not trustable.
like said already in THIS topic, pcmcia is not just for laptops.
it normal standard, just like PCI and it is foundable in desktops too.
_________________________
!

download KiXnet

Top
#76785 - 2003-09-23 12:51 AM Re: keyexist()
marck1 Offline
Fresh Scripter

Registered: 2000-07-16
Posts: 16
Loc: Rotterdam, The Netherlands
We have about 2500 desktops and 1500 laptops and this script does the job. But Kent you are right, it won’t work in EVERY situation. We are not using any desktops with cardreaders, so....

[ 23. September 2003, 00:54: Message edited by: marck1 ]

Top
#76786 - 2003-09-23 02:36 AM Re: keyexist()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Please see this posting for an update to this code.

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=004591

Top
#76787 - 2003-09-23 04:11 PM Re: keyexist()
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
marck1...

The code I posted above has never failed. It also does not depend on PCMCIA or power mgmt software. The key...as far as I know will only be there if there is a physical battery in the machine.

Everyone else...

If someone could prove it wrong I would really apreciate it. Dont know why you would use some big WMI script when all you have to do is check for a registry key. Besides...I wish I could say we wont have any Win9x machines soon...But Im sure they will be around for a while. And IS is not going to spend the resources in adding WMI capabilities to them.

[ 23. September 2003, 16:13: Message edited by: CitrixMan ]

Top
#76788 - 2003-09-23 04:17 PM Re: keyexist()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
A UPS connected to a computer will also be detected as a battery. PCMCIA cards can be present in computers as well. The case type in WMI is not always set to the correct value.

ScriptLogic has looked into this extensively and the best they could come up with is a proprietary solution, which they plan to patent.
_________________________
There are two types of vessels, submarines and targets.

Top
#76789 - 2003-09-23 04:31 PM Re: keyexist()
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Yes but a UPS connector will not show up in the registry key I specified. I have tested with PCs that have UPS connected...Like I said...If anyone can prove it to be faulty, Please do so.
Top
#76790 - 2003-09-23 05:52 PM Re: keyexist()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Everybody, please give this UDF a try: IsLaptop() - Determines whether a local/remote computer is a laptop .

The code below will display all computers in a domain and whether they're laptops or not. Windows 9x computers must have remote registry access enabled to be classified as laptop.
code:
$sComps=NetView2()
for each $sComp in $sComps
$iRC=IsLaptop($sComp,1)
select
case $iRC=-1
? $sComp+' is unknown'
case $iRC=1
? $sComp+' is a laptop'
case $iRC=0
? $sComp+' is not a laptop'
case 1
? 'undefined'
endif
next
exit 0

_________________________
There are two types of vessels, submarines and targets.

Top
#76791 - 2003-09-23 11:46 PM Re: keyexist()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Don't want to really run against my entire Domain right now as that takes hours to run, but so far on about a dozen computers it appears to work well.

Hopefully CitrixMan is correct.

I know WMI is a pig, but since you have to use it for some other things, nice to have another method of getting data.

This Reg method is quicker for sure, but if you want to get back the other data then this looks good too.
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=004591

[ 24. September 2003, 00:23: Message edited by: NTDOC ]

Top
#76792 - 2003-09-24 05:00 PM Re: keyexist()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I just wanted a quick binary IsLaptop check for the client-side, primarily login scripts. The WMI approach is more better suited for admin scripts, IMHO.
_________________________
There are two types of vessels, submarines and targets.

Top
#76793 - 2003-09-24 06:53 PM Re: keyexist()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well I haven't gotten there yet, but I'm hoping to run silent scripts with WKIX32.EXE and I want to probably sleep the script for maybe a couple minutes after logon before it starts to really do anything.

At that point as long as you are not stealing all the CPU cycles and bandwidth of the client, you should be able to do similar things like MS SMS does and do background processing.

I am currently re-writing my entire logon script (thus all the recent posts about repairing scripts and UDFs to support the NoVarInStrings)

Nice posting by Howard about the SetOptions. Seems some things are not a clear as one would initially think.

I'm assuming that this will be the best practice for my new script.

DIM $Set1,$Set2
$Set1=SetOption('Explicit','ON')
$Set2=SetOption('NoVarsInStrings','ON')

Top
#76794 - 2003-09-24 07:15 PM Re: keyexist()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
My standard script header:
code:
DEBUG OFF
BREAK OFF
if instr(@scriptdir,'beta') or instr(@scriptdir,'test')
BREAK ON
endif

Dim $iRC
$iRC=SETOPTION('Explicit','ON')
$iRC=SETOPTION('NoVarsInStrings','ON')
$iRC=SETOPTION('WrapAtEOL','ON')

$iRC=SETTITLE('Script Title')

$iRC=Main()

exit 0

_________________________
There are two types of vessels, submarines and targets.

Top
#76795 - 2003-09-25 06:20 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I had two days off from Office, It is glad to know that the topic is still hot. Any ways I checked Citrix man's script and sorry to say that I found that key(PNPOCOA) in 4 desktop PC's in my company which is Compaq D51C/P253. thees PC was having COMPBATT key too where my script failed first time.

I found NTDOC (WMI query) was only Possible but as somebody said WMI is good only for admin script, I found that if I add WMI script in my login script and machine doesn’t have WMI installed the entire script is failing to proceed.

I'll say what is my actual requirement to find laptop, My laptop users are taking their machines at home this is causing a virus threat, so we decided to write a script to check the dat version in laptop if it is old show a message to call help desk and log them off without further mercy !!

Pls let me know is there any other way to do this ... this is the requirement from or Vice president of I.T.

I'll post my old code

code:
$laptop=KeyExist("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt")
If $laptop=1
$datver=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\VirusScan Enterprise\CurrentVersion","szVirDefVer")
$srvdat=ReadProfileString("\\qasrvho\updates$\update.ini","SuperDat-IA32","DATVersion")
If ($datver=$srvdat)
? "same version"
Else
? "vier. is diffrent"
$msg=MessageBox ("Your virus deffnition files are old, Please call IT help desk immediatly!! You wont be able to login to network unless you have latest deffnition file","Virus file allert",16)
Logoff (1)
EndIf
EndIf

_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76796 - 2003-09-25 06:58 AM Re: keyexist()
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
quote:

was only Possible but as somebody said WMI is good only for admin script

If that is the case, install WMINT4.EXE/WMI9X.EXE to address this..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#76797 - 2003-09-25 11:03 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
It's a long way I guss, I have to find out the PC's which dosent have WMI and install it.....

I am looking for a quick solution.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
Page 2 of 2 <12


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

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.1 seconds in which 0.072 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org