Page 1 of 1 1
Topic Options
#71646 - 2002-11-19 07:54 PM Convert a logon-bat to a domain retreival
ArchAngel96 Offline
Getting the hang of it

Registered: 2002-10-20
Posts: 70
I've designed a logon script to inventory the hardware on our network. We've found that there are a number of users that do not logoff and on regularly, so now I'm interested in calling out to the machines, but still running the script (since I did so much work to it). is there a way to have it call out and inventory specific machines, via a list file?

code:
; script main
If Exist (c:\hardinvn.000)
Return
Else
EndIf
Gosub GetWMIInfo
Open (2, "\\nt-xxxxxx\logs$\HardwareInventory\hardinve.csv", 4) = 0
WriteLine (2, @WKSTA + "," + $WMIManufacturer
+ "," + $WMIModel + "," + $WMIModelVersion + ","
+ $WMIManufacturer2 + "," + $WMIBiosSernum + ","
+ $WMICPUCurrentClockSpeed + "," +
$WMITotalPhysicalMemory + "," + $WMICDriveSize + "," + $WMICDriveFreeSpace + "," +
$WMIDisplayDescription + "," + $WMINICName + ","
+ $WMISoundCard + "," + $WMICDRom + "," + @PRODUCTTYPE + "," + @CSD + @CRLF)
;Else
; ? "Failed to open file"
Close (2)
Open (1, c:\hardinvn.000, 5)
Close (1)
Return
Exit
; main end

;***************************
;* sub GetWMIInfo *
;***************************
:GetWMIInfo
If @INWIN$ = 1
$WMIManufacturer = Rtrim(WMIQuery("Manufacturer", "Win32_ComputerSystem"))
$WMIModel = Rtrim(WMIQuery("Model", "Win32_ComputerSystem"))
$WMIManufacturer2 = Rtrim(WMIQuery("Version", "Win32_ComputerSystemProduct"))
$WMIBiosVersion = Rtrim(WMIQuery("Version", "Win32_BIOS"))
$WMIBiosSernum = Rtrim(WMIQuery("SerialNumber", "Win32_BIOS"))
$WMISMBIOSVersion = Rtrim(WMIQuery("SMBIOSVersion", "Win32_BIOS"))
$WMICPUCurrentClockSpeed = Rtrim(WMIQuery("CurrentClockSpeed", "Win32_Processor"))
$WMITotalPhysicalMemory = Rtrim(WMIQuery("TotalPhysicalMemory", "Win32_LogicalMemoryConfiguration"))
$WMICDrive = Rtrim(WMIQuery("Caption", "Win32_LogicalDisk"))
If InStr($WMICDrive,"|")
For Each $Return in Split($WMICDrive,"|")
If $Return $WMICDrive=$Return EndIf
Next
EndIf
$WMICDriveSize = Rtrim(WMIQuery("Size", "Win32_LogicalDisk"))
If InStr($WMICDriveSize,"|")
For Each $Return in Split($WMICDriveSize,"|")
If $Return $WMICDriveSize=$Return EndIf
Next
EndIf
$WMICDriveFreeSpace = Rtrim(WMIQuery("FreeSpace", "Win32_LogicalDisk"))
If InStr($WMICDriveFreeSpace,"|")
For Each $Return in Split($WMICDriveFreeSpace,"|")
If $Return $WMICDriveFreeSpace=$Return EndIf
Next
EndIf
$WMIDisplayDescription = Rtrim(WMIQuery("Description", "Win32_DisplayControllerConfiguration"))
$WMINICName = Rtrim(WMIQuery("Caption", "Win32_NetworkAdapterConfiguration"))
If InStr($WMINICName,"|")
For Each $Return in Split($WMINICName,"|")
If $Return $WMINICName=$Return EndIf
Next
EndIf
$WMISoundCard = Rtrim(WMIQuery("Caption", "Win32_SoundDevice"))
$WMICDRom = Rtrim(WMIQuery("Caption", "Win32_CDROMDrive"))
If InStr($WMICDRom,"|")
For Each $Return in Split($WMICDRom,"|")
If $Return $WMICDRom=$Return EndIf
Next
EndIf
EndIf
Return

;***************************
;* function WMIQuery *
;***************************
Function WMIQuery($what, $where)
Dim $strQuery, $objEnumerator, $value
$strQuery = "Select $what From $where"
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 AND $objInstance <> ""
$junk = Execute("$$value = $$objInstance.$what")
$WMIQuery = "$value" + "|" + "$WMIQuery"
EndIf
Next
$WMIQuery = Left($WMIQuery, Len($WMIQuery) - 1)
EndFunction

any one have any ideas???? For those of you that have seen/helped my posts before... I have another lawn dart.

[ 19. November 2002, 20:27: Message edited by: ArchAngel96 ]
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?

Top
#71647 - 2002-11-19 08:01 PM Re: Convert a logon-bat to a domain retreival
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
could you break this:
WriteLine (2, @WKSTA + "," + $WMIManufacturer ...

line.
you can do:
WriteLine (2, @WKSTA + ","
+ $WMIManufacturer

after all + signs and it will not break the script.
it's hard to read now
_________________________
!

download KiXnet

Top
#71648 - 2002-11-19 08:18 PM Re: Convert a logon-bat to a domain retreival
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Please break your long line as it really messes the thread.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71649 - 2002-11-19 08:39 PM Re: Convert a logon-bat to a domain retreival
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You can get the updated version of WMIQuery from the UDF library. If you specify the optional $Computer variable, you can run the query against a remote PC.
Top
#71650 - 2002-11-19 08:45 PM Re: Convert a logon-bat to a domain retreival
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dirty postcount there!

copy&paste code is avail at www.gwspikval.com/jooel/UDF
_________________________
!

download KiXnet

Top
#71651 - 2002-11-19 08:52 PM Re: Convert a logon-bat to a domain retreival
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use the COMNetView UDF to enumerate a list of computers on the network. Then use WMIQuery to query the remote computers based on the list.

Finally, please read ABC's of KiXtart board etiquette and message to new forum users , Section E.
_________________________
There are two types of vessels, submarines and targets.

Top
#71652 - 2002-11-19 09:59 PM Re: Convert a logon-bat to a domain retreival
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I had to post another reply to get rid of that evil postcount. [Eek!] [Wink]
Top
#71653 - 2002-11-19 11:15 PM Re: Convert a logon-bat to a domain retreival
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
So that is NOT your true self? [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#71654 - 2002-11-19 11:25 PM Re: Convert a logon-bat to a domain retreival
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I guess it was one of those "you had to be there" things since the post count has since changed. Assume the post count was 666.
_________________________
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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.066 seconds in which 0.033 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