Code: Alles auswählen
#include "common.ch"
#include "os.ch"
#define CRLF CHR(13)+CHR(10)
#PRAGMA LIBRARY("ASCOM10.LIB")
PROCEDURE Main(strComputer,cUser,cPassword)
LOCAL objWMIServices
LOCAL colItems
LOCAL cText
LOCAL cName
LOCAL bCollBlock
LOCAL i,iMax
LOCAL j,jMax
LOCAL aitem := {}
// alle Propertys
LOCAL aProp := {;
"Capacity",;
"Caption",;
"CleanerMedia",;
"CreationClassName",;
"Description",;
"HotSwappable",;
"InstallDate",;
"Manufacturer",;
"MediaDescription",;
"MediaType",;
"Model",;
"Name",;
"OtherIdentifyingInfo",;
"PartNumber",;
"PoweredOn",;
"Removable",;
"Replaceable",;
"SerialNumber",;
"SKU",;
"Status",;
"Tag",;
"Version" }
DEFAULT strComputer TO "Localhost"
DEFAULT cUser TO "Administrator"
DEFAULT cPassword TO ""
CLS
SET ALTER TO Win32_PhysicalMedia.TXT
SET ALTER ON
IF VAL( OS(OS_VERSION) ) > 6
IF strComputer == "Localhost"
objWMIServices := CreateObject( "WbemScripting.SWbemLocator" ):ConnectServer(strComputer, "Root\CIMv2")
ELSE
IF EMPTY(cPassword)
MSGBOX("Need Password")
QUIT
ELSE
objWMIServices := CreateObject( "WbemScripting.SWbemLocator" ):ConnectServer(strComputer, "Root\CIMv2",strComputer+"\"+cUser,cPassword)
ENDIF
ENDIF
ELSE
objWMIServices := GetObject("WinMgmts:{impersonationLevel=impersonate}\\"+strComputer+"\Root\CIMv2")
ENDIF
colItems := objWMIServices:ExecQuery("select * from Win32_PhysicalMedia",,48)
bCollBlock := {|oService,n| AADD(aItem,{ n,;
oService:getProperty("Capacity"),;
oService:getProperty("Caption"),;
oService:getProperty("CleanerMedia"),;
oService:getProperty("CreationClassName"),;
oService:getProperty("Description"),;
oService:getProperty("HotSwappable"),;
oService:getProperty("InstallDate"),;
oService:getProperty("Manufacturer"),;
oService:getProperty("MediaDescription"),;
oService:getProperty("MediaType"),;
oService:getProperty("Model"),;
oService:getProperty("Name"),;
oService:getProperty("OtherIdentifyingInfo"),;
oService:getProperty("PartNumber"),;
oService:getProperty("PoweredOn"),;
oService:getProperty("Removable"),;
oService:getProperty("Replaceable"),;
oService:getProperty("SerialNumber"),;
oService:getProperty("SKU"),;
oService:getProperty("Status"),;
oService:getProperty("Tag"),;
oService:getProperty("Version") })}
ComEvalCollection(colItems, bCollBlock )
IF LEN(aItem) > 0
? "Win32_PhysicalMedia"
jMax := LEN(aItem)
iMax := LEN(aItem[1])
FOR j := 1 TO jMax
?"*****************************************************************************"
FOR i := 1 TO iMax-1
? SUBSTR(aProp[i]+SPACE(40),1,40)+":",aItem[j,i+1]
NEXT
?"*****************************************************************************"
NEXT
ELSE
MSGBOX("no Property found ?")
ENDIF
SET ALTER OFF
SET ALTER TO
Runshell("Win32_PhysicalMedia.TXT","Notepad.exe",.T.)
RETURN
wenn du nur die SerialNumber haben willst dann entferne alle anderen Propertys aus dem Array aProp / oService:getProperty()