Page 1 of 2 12>
Topic Options
#76763 - 2003-09-22 09:44 AM keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
code:
$ReturnCode = KeyExist("HKEY_CURRENT_USER\Console")
If $ReturnCode=1
? "Key exists...."
EndIf


Key exist fuction is not returning any thing !! any idea??
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76764 - 2003-09-22 10:00 AM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
quote:

Key exists....
0 - The operation completed successfully.

No probs here.
This key only exist after logon using win9x if I recall correctly.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76765 - 2003-09-22 10:00 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Now I change the script to read the value but still not working

quote:

Call "d:\kix\udf\netview2.udf"
$computerlist=NetView2()
For Each $computer In $computerlist
$PRODUCTTYPE=ReadValue('\\'+$computer+'\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS','PRODUCTTYPE')
If $PRODUCTTYPE="WinNT"
$regkey='\\'+$computer+'\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$regvalue='CurrentVersion'
If ReadValue($regkey,$regvalue)='5.0'
? "$computer 2k"
$RDD=ReadValue('\\'+$computer+'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt','DisplayName')
? $rdd
If ($RDD="Microsoft Composite Battery Driver")
? "$computer is laptop"
Open(1,"C:\laptop2k.TXT",5)
WriteLine (1,"$computer"+@CRLF)
Close(1)
EndIf
EndIf
EndIf
Next

This job is very urgent for me pls help...

I am running the script from w2k PC my KIX ver is 4.21
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76766 - 2003-09-22 10:02 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
it is not returning 0 or 1 [Roll Eyes]
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76767 - 2003-09-22 10:04 AM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
Change this...
quote:

('\\'+$computer+'\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS','PRODUCTTYPE')

to this...
quote:

('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS','PRODUCTTYPE')

This works for me on W2K.

Did a simple check with this

code:
$computer = @WKSTA
$PRODUCTTYPE=ReadValue('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS','PRODUCTTYPE')
? "$producttype...."
? "@ERROR - @SERROR"

Sleep 3

Why not just use @PRODUCTTYPE

[ 22. September 2003, 10:11: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76768 - 2003-09-22 10:10 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
That line is ok for me

Just runt this line in ur pc

code:
$RDD=KeyExist('\\'+remotepc+'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt')
$RDDL=KeyExist("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt")
? "$rdd"
? "$rddl"

just see $rdd and $rddl is returning "0" or "1"
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76769 - 2003-09-22 10:21 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
you are right buddy that was the issue, now it is working, basically I am trying to find out laptop's in my network here is my latest code.

code:
 
Call "d:\kix\udf\netview2.udf"
$computerlist=NetView2()
For Each $computer In $computerlist
$PRODUCTTYPE=ReadValue('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS','PRODUCTTYPE')
If $PRODUCTTYPE="WinNT"
$regkey='\\'+$computer+'\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$regvalue='CurrentVersion'
If ReadValue($regkey,$regvalue)='5.0'
? "$computer 2k"
$RDD=KeyExist('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt')
? $rdd
If ($RDD=1)
? "$computer is laptop"
Open(1,"C:\laptop2k.TXT",5)
WriteLine (1,"$computer"+@CRLF)
Close(1)
EndIf
EndIf
EndIf
Next

but I foung the reg. key which I am serching for LAptop is existing in some of my compaq PC's (D51c HP) can some body tell me any uneeque key which is only there in Laptop ??
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76770 - 2003-09-22 10:24 AM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
Why don't you use @PRODUCTTYPE [Confused]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76771 - 2003-09-22 10:30 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
@PRODUCTTYPE wont say the PC is LAPTOP or normal !!
quote:

@PRODUCTTYPE
OS type. Possible values:
"Windows 95"
"Windows 98"
"Windows Me"
"Windows NT Workstation"
"Windows NT Server"
"Windows NT Domain Controller"
"Windows 2000 Professional"
"Windows 2000 Server"
"Windows 2000 Domain Controller"
"Windows XP Home Edition"
"Windows XP Professional"
"Windows XP Server"
"Windows XP Domain Controller"

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

Top
#76772 - 2003-09-22 10:38 AM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
Yep. But I don’t see you using the producttype to find out if it’s a laptop or not.

This...
quote:

$RDD=KeyExist('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt')

...is used to see if it's a laptop or not. So I don't see any reason why the @PRODUCTTYPE can't be used. But everybody has its own preferences so if you like it better this way it's OK [Embarrassed]

BTW,
There’s still one little error in your script [Wink]

quote:

$regkey='\\'+$computer+'\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion'



[ 22. September 2003, 10:38: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76773 - 2003-09-22 10:56 AM Re: keyexist()
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
As i said @producttype will not say the Machine is LAPTOP or normal PC then waht is the point of using it ?

another thing

quote:

$RDD=KeyExist('\\$computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CompBatt')


I found this key in few desktop PC's too, what else I can do to find out LAPTOP's??
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#76774 - 2003-09-22 11:14 AM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
In your script the productype is checked by looking into the registry and used to startup the laptop or desktop check. Checking on @PRODUCTTYPE will also give you Windows NT, 2000, XP or whatever. Saved the time to create a script that looks into the registry and eliminates possible errors.

I've seen some people doing a check in the registry is any PCMCIA ports are installed (I think Radimus said some words about this some a few weeks ago). A standard desktop pc will not have PCMCIA ports installed.

A check on @CPU might also do the trick. If you're laptops are recent there is a good change that they have a Pentium Mobile CPU. Not sure if @CPU returns the correct value for a mobile CPU because I can't test this now.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

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

Registered: 2001-06-05
Posts: 22303
Loc: OK
ja.
my laptop is already 2 years old. [Frown]
it says "Intel Pentium III"
_________________________
!

download KiXnet

Top
#76776 - 2003-09-22 02:05 PM Re: keyexist()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4641
Loc: The Netherlands
OK, that sucks. There must be some other way then.
I'm almost sure I've seen something about checking for PCMCIA ports using WMI or reg checks or something. A few weeks ago.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76777 - 2003-09-22 02:25 PM Re: keyexist()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=004556

basically, compbatt, will exist on laptops and desktops with smart UPSs

pcmcia cards are usually only in laptops, but not all... some PCs have them for smartcard readers.

and some laptops bios may or may not provide the case type... like old inspiron 7000s, but newer ones will.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#76778 - 2003-09-22 04:39 PM Re: keyexist()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
I thought I saw the discussion at the end of last week.
_________________________
!

download KiXnet

Top
#76779 - 2003-09-22 05:35 PM Re: keyexist()
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Here you go..
code:
BREAK ON
CLS
;Requires WMIQuery > http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000117
;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_systemenclosure.asp
;Thanks Radimus for the inspiration!!
$casetype=WMIQuery('ChassisTypes','Win32_SystemEnclosure')[0]

?$casetype

FOR EACH $lt IN split($casetype, '8,9,10,11')
$lt="Lap"
NEXT

IF $lt<>""
?'PORTABLE'
ELSE
?'DESKTOP'
ENDIF

get $k

;Portable units would be
;--
;8 Portable
;9 Laptop
;10 Notebook
;11 Hand Held

;Desktops would be
;--
;1 Other
;2 Unknown
;3 Desktop
;4 Low Profile Desktop
;5 Pizza Box
;6 Mini Tower
;7 Tower
;12 Docking Station
;13 All in One
;14 Sub Notebook
;15 Space-Saving
;16 Lunch Box
;17 Main System Chassis
;18 Expansion Chassis
;19 SubChassis
;20 Bus Expansion Chassis
;21 Peripheral Chassis
;22 Storage Chassis
;23 Rack Mount Chassis
;24 Sealed-Case PC

Thanks,

Kent

[ 22. September 2003, 17:36: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#76780 - 2003-09-22 08:31 PM Re: keyexist()
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2078
Loc: Tulsa, OK
Does WMI work on Win9x? If not here is the code I have used in the past. Seems to always work for me.

code:
 
If KeyExist("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI\PNP0C0A") or KeyExist("HKEY_LOCAL_MACHINE\Enum\ACPI\*PNP0C0A")
$msg = messagebox ("This is a laptop!!","laptop",0)
Else
$msg = messagebox ("This is not a laptop!!","laptop",0)
Endif


Top
#76781 - 2003-09-22 11:55 PM Re: keyexist()
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Work on 9x, natively - no.

You will need to download the following files for 9x/NT.

WMI9X.EXE/WMINT4.EXE

2k/XP/2K3 have WMI built-in.

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

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

Registered: 2000-07-16
Posts: 16
Loc: Rotterdam, The Netherlands
Hi,

The following code is used to determine a W2K laptop:

$PCMCIA=READVALUE("HKLM\SYSTEM\CurrentControlSet\Services\Pcmcia","Start")
? "If Value PCMCIA Is 0 Than This Is A Laptop, Else A Desktop, Value Is $PCMCIA"

The following is used for W9x

$PCMCIA=EXISTKEY("HKLM\System\CurrentControlSet\Services\Class\PCMCIA\0000")
IF $PCMCIA=0
? "This Is A Laptop"
ENDIF

I hope this is useful.

regards,

Marck

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 150 anonymous users online.
Newest Members
Hdrthtsr19956, Kylie99, msmile042, rayd8, HardKn0X
17597 Registered Users

Generated in 0.093 seconds in which 0.032 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