Page 1 of 2 12>
Topic Options
#71369 - 2002-11-05 10:33 AM Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
may be it is a old issue but I am sorry i am not getting a proper solution for this, My problem is...

I want to get PC serial no and processor speed computer name wise in a file I tried using WMI wmiquiry is not working in my PC my OS : NT4, Domain NT4

When I try using this query $SerNo =WMIQuery("SerialNumber","Win32_BIOS")
? $serno

kix2k returns me script error: expected expression! $serNo=WMIQuery("SerialNumber","Win32_bios")


may be I don’t know how to use WMI ?? PLS help me

The alternat utility I found is SMBIOS, this thing dump the full information about the bios, now how can I filter only serial no and processer speed to a text file or smilar file ?

Regards

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

Top
#71370 - 2002-11-05 11:27 AM Re: Off topic about pc serial...
Wokkeltje Offline
Fresh Scripter

Registered: 2002-08-12
Posts: 31
Loc: Torhout, Belgium
WMI is not a default NT thing, you will need to install 'wmicore.EXE'.

You find it at the MS site

Top
#71371 - 2002-11-05 11:40 AM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I have dowloaded and installed wmicore.exe...
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#71372 - 2002-11-05 02:22 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
WMIQuery is also a function... it needs to be available in the script that you would be using.

and kix 4+, of course....
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71373 - 2002-11-05 04:12 PM Re: Off topic about pc serial...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See How to use UDFs and WMIQuery() - Used to execute a query against WMI
_________________________
There are two types of vessels, submarines and targets.

Top
#71374 - 2002-11-05 09:24 PM Re: Off topic about pc serial...
ylekiot Offline
Fresh Scripter

Registered: 2002-06-18
Posts: 8
I have something similar that I use. I use the smb16.exe utility (related to the smbios.exe)

first I have this is the login script
to run the smb16.exe find serial number and pipe out lines
33 and 35 due to multiple serial numbers being outputed (computer serial and motherboard serial for example) It then runs a kix script to get os version, computer name, Norton AVCE 7.5 virus definition date stamp, IE version, serial number, product name (computer model) name and userid.
Its a thrown together solution but it works 100%on all of my ibm pcs (95% on the serial number and product name)

I also have my script set up (not shown here) to only run on 9x, nt wrkstn and 2k pro with %OS% variables and gettype.exe

Good luck

[Cool]

IN LOGIN SCRIPT

if exist c:\ibm.txt goto dat
\\usut809\netlogon\smb16.exe>c:\ibm.txt
:dat
if exist c:\ibm.dat goto srvr
type c:\ibm.txt|find "serial number" /i /n|find "35">c:\ibm.dat
type c:\ibm.txt|find "product name" /i /n|find "33">>c:\ibm.dat
:os

:srvr
cls

\\usut809\netlogon\kix32.exe \\usut809\netlogon\osie.scr

THE KIX FILE OSIE.SCR

IF (@inwin = 1)
$NT_mode="yes"
ELSE
$NT_mode="no"
ENDIF

$os=""
$os_dos=@dos
$ie_product=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer","Version")
$os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
$os_productSuite=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite")
$os_service_pack=""
$os_subversion=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber")
SELECT
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="XP_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") ; - Windows XP Server
$os="XP_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") AND ($os_productSuite = "personal") ; - Windows XP Home
$os="XP_Home"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") ; - Windows XP Professional
$os="XP_Professional"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="W2K_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") ; - Windows 2000 -
$os="W2K_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.0")
$os="W2K_Professional"
CASE ($NT_mode = "yes") AND ($os_product = "LANMANNT") ; - Windows NT -
$os="NT4_Domain_Controller"
CASE ($NT_mode = "yes") AND ($os_product = "ServerNT") AND (Instr($os_productSuite,"Terminal Server") <> 0)
$os="NT4_Terminal_Server"
CASE ($NT_mode = "yes") AND ($os_product = "ServerNT")
$os="NT4_Member_Server"
CASE ($NT_mode = "yes") AND ($os_product = "WinNT")
$os="NT4"
CASE ($NT_mode <> "yes") AND (@dos = "4.90")
$os="ME"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 98 -
$os="W98c"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"b") <> 0)
$os="W98b"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"a") <> 0)
$os="W98a"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10")
$os="W98"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 95 -
$os="W95c"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"b") <> 0)
$os="W95b"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"a") <> 0)
$os="W95a"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0")
$os="W95"
CASE 1
$os="???" ; - undetermined -
ENDSELECT
;
$os_service_pack=""
SELECT
CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","BuildLab")
IF (len($os_service_pack) <> 0)
$os_service_pack=LTRIM(RTRIM($os_service_pack))
$os=substr($os,1,3)+"_"+LTRIM(RTRIM($os_service_pack))
ENDIF
CASE ($NT_mode = "yes") AND ($os_dos <> "5.1") ; Windows NT4 + W2K
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","CSDVersion")
IF (len($os_service_pack) <> 0)
$os_service_pack=LTRIM(RTRIM($os_service_pack))
IF (instr($os_service_pack,",") <> 0)
$os=substr($os,1,3)+"_"+substr($os_service_pack,instr($os_service_pack,",")-1,1)
ELSE
$os=substr($os,1,3)+"_"+substr($os_service_pack,len($os_service_pack),1)
ENDIF
ENDIF
CASE 1
; Windows 95, 98 + ME
ENDSELECT
;
$os_type=""
$os_dos=@dos
SELECT
CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP -
$os_type="XP"
CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 -
$os_type="W2K"
CASE ($NT_mode = "yes") ; - Windows NT -
$os_type="NT4"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME -
$os_type="ME"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 -
$os_type="W98"
CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 -
$os_type="W95"
CASE 1
$os_type="???" ; - undetermined -
ENDSELECT
$os_type=LTRIM(RTRIM(substr($os_type+" ",1,3)))
;

$vird=readprofilestring("c:\program files\common files\symantec shared\virusdefs\definfo.dat","DefDates","CurDefs")
open(1,"c:\ibm.dat",2)
$abc=readline(1)
$def=readline(1)
$abc1=substr($abc, len($abc)-6,28)
$def1=substr($def, len($def)-6,28)
close(1)
REDIRECTOUTPUT ("K:\PCUPDATE\LOG\OSie.TXT",0)
? "@hostname $OS @USERID $ie_product $vird $abc1 $def1 @fullname"
REDIRECTOUTPUT ("c:\osie.txt",0)
? "@hostname $OS @USERID $ie_product $vird $abc1 $def1 @fullname"
?

Top
#71375 - 2002-11-05 09:35 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
well...

code:
	$CPUsp	=@mhz
if instr($CPUsp,"179") $CPUsp=1800 endif
if instr($CPUsp,"106") $CPUsp=1100 endif
if instr($CPUsp,"702") $CPUsp=700 endif
$modem =WMIQuery("Description","Win32_POTSModem",,"Status","OK")
$Printer=WMIQuery("DriverName","Win32_Printer",,"SystemName","@wksta")
$Video =WMIQuery("Description","Win32_VideoController")
$HD =WMIQuery("Size","Win32_DiskDrive")
$hdGB =left($hd,len($hd)-9)
$hdMBfr =GetDiskSpace("c:")/1000
$Make =WMIQuery("Manufacturer","Win32_ComputerSystem")
$Model =WMIQuery("Model","Win32_ComputerSystem")
$Biosv =WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")
$biosd =WMIQuery("Version","Win32_BIOS")
$asset =WMIQuery("SMBIOSAssetTag","Win32_SystemEnclosure")
if instr($asset,"|")
for each $return in split($asset,"|")
if $return $asset=$return endif
next
endif
$SerNo =WMIQuery("SerialNumber","Win32_BIOS")
if len($SerNo) < 2
$SerNo=WMIQuery("SerialNumber","Win32_SystemEnclosure")
if instr($serno,"|")
for each $return in split($serno,"|")
if len($return)<10 $serno=$return endif
next
endif
endif
$SerNo =trim(ucase($SerNo))
$dimms=Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
for $a=0 to ubound($dimms)
$=execute("$$dimm$a=val($$dimms[$a]) / 1048576")
$=execute("$$memory=val($$Memory)+val($$dimm$a)")
next

select
Case @producttype = "Windows 2000 Professional" $os="Win2K" $ostype="WinNT"
Case @producttype = "Windows NT Workstation" $os="WinNT" $ostype="WinNT"
endselect
$ier =readvalue("$HKLMS\Microsoft\Internet Explorer", "Version")
$MSOdir =readvalue("$HKLMSMWCV\App Paths\excel.exe","Path")
$access =getfileversion("$MSOdir\msaccess.exe")
$excel =getfileversion("$MSOdir\excel.exe")
$outlook =getfileversion("$MSOdir\outlook.exe")
$powerpnt =getfileversion("$MSOdir\powerpnt.exe")
$pub =getfileversion("$MSOdir\mspub.exe")
$Word =getfileversion("$MSOdir\winword.exe")

etc...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71376 - 2002-11-05 10:16 PM Re: Off topic about pc serial...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Rad,

I realize this was probably just an example... but please include your path selections, DIMs, UDFs, etc, when posting code.

$MSOdir means nothing as is. The code also is missing Endselect, etc...

Just don't want others to come by and think this is complete working code, and then complain why such and such is not working.

Top
#71377 - 2002-11-05 10:35 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
true... I just posted the relevant portions of my script as a comparison to the post prior.

But then Les would be upset when it has long lines... [Big Grin]

The complete script is 63k.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71378 - 2002-11-06 11:01 AM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Thax for the replies

Can some body explain how to use this ADSI or WMI quiries in kix script ( I may be dump [Frown] )Pls because I am using it first time..

I am using kix ver 4

I tried Radims script it is giving same error msg...

It seems yelkot script will do the job I have to dump full bios information to a text file then filter only seerila no. part etc...

I need valuable suggetion of u guys about which one is the best I mean wmi or smbios ....

regards

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

Top
#71379 - 2002-11-06 04:05 PM Re: Off topic about pc serial...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Did you actually read my reply further up?

quote:
See How to use UDFs and WMIQuery() - Used to execute a query against WMI
WMI is better.

[ 06. November 2002, 16:06: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#71380 - 2002-11-06 06:05 PM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Oh ya I read that link, I even tried to work with Radimus script it seems my sys tem is not understanding wmiquery though I installed wmicore, I got it from MS site it was they called it wmicore for 98,95 and NT. Radimus script was failing on the fist function It was giving the error msg which I stated my fist posting.

I have copied and pasted his script just like that, could u pls tell me where I have to make changes ?

will it work with Kix3.63 ?

It seems I have to lern more about writing functions and ading it in the script... : confused:
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#71381 - 2002-11-06 06:21 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
WMIQuery() is a Function.

Functions are only available in kix 4 or better

for a function to work in a script, the function "body" must be included in the script somewhere.

Read the post about how to use UDFs
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71382 - 2002-11-06 06:29 PM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I have added ur fuction to my script
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000117

could u pls suggest me where i have to make changes in ur script ?
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#71383 - 2002-11-06 06:37 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
post your code so we can see what is happening
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71384 - 2002-11-06 06:44 PM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
BREAK ON CLS? "System Manufacturer is = "WMIQuery("Manufacturer","Win32_ComputerSystem")? "System Model is = "WMIQuery("Model","Win32_ComputerSystem")? "System Serial Number is = "WMIQuery("SerialNumber","Win32_BIOS")? "System BIOS Version is = "WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")? "System BIOS Date is = "WMIQuery("Version","Win32_BIOS")? "CPU Speed is = "WMIQuery("CurrentClockSpeed","Win32_Processor") " Mhz"? "System Memory = "val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 " MB"for each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|") ? "Dimm Size = "val($dimm) / 1048576 " MB" next? "Video Card is = "WMIQuery("Description","Win32_VideoController")? "Video Res is = "WMIQuery("VideoModeDescription","Win32_VideoController")? "Modem is = "WMIQuery("Description","Win32_POTSModem")for each $nic in Split(WMIQuery("ProductName","Win32_NetworkAdapter"),"|") if instr($nic,"miniport")=0 and instr($nic,"RAS")=0 and instr($nic,"Parallel")=0 ? "Network Card is = "$nic endif next

FUNCTION WMIQuery($what,$from,optional $computer,optional $where, optional $x) dim $strQuery, $objEnumerator, $value if not $computer $computer="@WKSTA" endif $strQuery = "Select $what From $from" if $where and $x $strQuery = $strQuery + " Where $where = '$x'" endif $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer") $objEnumerator = $SystemSet.ExecQuery($strQuery) For Each $objInstance in $objEnumerator If @Error = 0 and $objInstance <> "" $=execute("$$value = $$objInstance.$what") $WMIQuery="$value"+"|"+"$WMIQuery" EndIf Next $WMIQuery=left($WMIQuery,len($WMIQuery)-1) exit @error
ENDFUNCTION

after installing WMICORE I just copied and paste ur code like this, Now pls tell me where I have to make changes in ur code.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#71385 - 2002-11-06 06:46 PM Re: Off topic about pc serial...
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Oh sory for that text it is correct order in my script...
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#71386 - 2002-11-06 07:01 PM Re: Off topic about pc serial...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
It is kind of hard to read, but the usual problems are:

missing quotes
endifs

I suggest that you make a simple script like this one:
code:
? @kix
? WMIQuery("SerialNumber","Win32_BIOS")
? @Serror

exit
;****************************************************************************************************
FUNCTION WMIQuery($what,$from,optional $computer,optional $where, optional $x)
dim $strQuery, $objEnumerator, $value
if not $computer $computer="@WKSTA" endif
$strQuery = "Select $what From $from"
if $where and $x $strQuery = $strQuery + " Where $where = '$x'" endif
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 and $objInstance <> ""
$=execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
EndIf
Next
$WMIQuery=left($WMIQuery,len($WMIQuery)-1)
exit @error
ENDFUNCTION



[ 06. November 2002, 21:56: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71387 - 2002-11-06 07:14 PM Re: Off topic about pc serial...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please post your code between [CODE] tags as specified in
ABC's of KiXtart board etiquette and message to new forum users

[ 06. November 2002, 20:38: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#71388 - 2002-11-06 07:19 PM Re: Off topic about pc serial...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...and managing long lines is mentioned within that FAQ.

How hard can it be?

Topic: Jooel, it is possible to break long lines
_________________________
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 2 12>


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

Who's Online
0 registered and 895 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.038 seconds in which 0.013 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