Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tore Bleken
  Where is Tore Bleken?
 Stokke
 Norway
 Tore Bleken
 To: naveed ahmad
  Where is naveed ahmad?
 peshawar
 Pakistan
 naveed ahmad
 Tags
Subject: RE: Hard Disk Serial Number Problem
Thread ID: 393678 Message ID: 393689 # Views: 55 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Saturday, December 21, 2013 6:24:19 PM         
   


> hi Experts.
> its problem repeated many times and i have tried many queries but didn't get a proper result.
> when i check it my system it works proper but when i copy another system then not work, please help me to solve it.
> i am using following codes
>
> Create Cursor myDisks (DriveLetter c(1),SerialNumber c(50),Model c(50),DeviceID c(50),VolumeName c(50),VolumeSerialNumber c(20))
>
> wmiServices = Getobject("winmgmts:{impersonationLevel=Impersonate}!//.")
> wmiDiskDrives = wmiServices.ExecQuery("SELECT Model,DeviceID FROM Win32_DiskDrive")
>
> For Each wmiDiskDrive In wmiDiskDrives
> lcDeviceID = Trim(Strtran(wmiDiskDrive.DeviceID,'\','\\'))
> wmiDiskPartitions = wmiServices.ExecQuery(;
> 'ASSOCIATORS OF {Win32_DiskDrive.DeviceID="' +;
> m.lcDeviceID + '"} WHERE '+ ;
> 'AssocClass = Win32_DiskDriveToDiskPartition')
>
> For Each wmiDiskPartition In wmiDiskPartitions
> wmiLogicalDisks = wmiServices.ExecQuery( ;
> 'ASSOCIATORS OF {Win32_DiskPartition.DeviceID="'+;
> wmiDiskPartition.DeviceID + '"} WHERE '+;
> 'AssocClass = Win32_LogicalDiskToPartition')
>
> For Each wmiLogicalDisk In wmiLogicalDisks
> wmiDiskVolumes = wmiServices.ExecQuery(;
> "Select deviceID,VolumeName,VolumeSerialNumber from Win32_LogicalDisk"+;
> " where deviceID = '" + wmiLogicalDisk.deviceID + "'" )
> For Each oVolume In wmiDiskVolumes
> lcVolumeName = oVolume.VolumeName
> lcVolumeSerialNumber = oVolume.VolumeSerialNumber
> Exit
> Endfor
>
> wmiDisks = wmiServices.ExecQuery(;
> 'SELECT * FROM Win32_PhysicalMedia where Tag="'+m.lcDeviceID+'"')
> For Each wmiDisk In wmiDisks
> Insert Into myDisks ;
> (DriveLetter,SerialNumber,Model,DeviceID,VolumeName,VolumeSerialNumber) ;
> values ;
> (wmiLogicalDisk.DeviceID,;
> wmiDisk.SerialNumber,;
> wmiDiskDrive.Model,;
> wmiDiskDrive.DeviceID,;
> m.lcVolumeName,;
> m.lcVolumeSerialNumber)
> Endfor
> Endfor
> Endfor
> Endfor
>
> regards.

Try this code:

Create Cursor PhysicalMedia (serialno c(100))
strComputer = [.]
objWMI = Getobject([winmgmts:\\] + strComputer + [\root\cimv2])
colClass = objWMI.ExecQuery([Select * from Win32_PhysicalMedia], , 48)

For Each objClass In colClass
   If !Isnull(objClass.serialnumber)
      Insert Into PhysicalMedia (serialno) Values (objClass.serialnumber)
   Endif
Next
Browse Normal


There's a fine line between helping and adding to the confusion.

How to create sample data

ENTIRE THREAD

Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/21/2013 1:58:34 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/21/2013 2:32:54 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/21/2013 2:39:56 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/21/2013 4:05:43 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 8:35:33 AM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/23/2013 2:51:58 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 3:22:47 PM
RE: Hard Disk Serial Number Problem Posted by Pete Sass @ 12/24/2013 8:11:42 PM
RE: Hard Disk Serial Number Problem Posted by Tore Bleken @ 12/21/2013 6:24:19 PM
RE: Hard Disk Serial Number Problem Posted by naveed ahmad @ 12/23/2013 8:32:47 AM