Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display C drive serial Number on a web page 1

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
Any body knows how to Display C drive serial Number on a web page? It like the getvolumeinformation in VB, I need to create an input text to display it.
Thanks for help
 
Here is a routine to get it. It is a short leap of logic from here to display it on a web page:

Code:
zPassword = InputBox "Enter your password"
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
on error resume next
Set objService = objLocator.ConnectServer(Computername,"root\cimv2","DOMAIN\Administrator",zPassword)
if err.number = 0 then
  call HDInfo()
end if
wscript.quit

sub HDInfo()
  query = "select manufacturer, description, caption, interfacetype, partitions, size, scsibus, scsitargetid, status " _
          & "from win32_diskdrive"
  
  Set objInstance = objService.ExecQuery(query)

  for each item in objInstance
    if strOS = "2000" then
      strDiskDescription = item.Caption
    else
      strDiskDescription = item.manufacturer & " " & item.Description
    end if
     
    zStatus = item.Status
    iPartitions = item.partitions
    zType = item.interfacetype 
    zSize = fFormatNum(item.size,false)
    
    zSCSIBusNo = item.scsibus     
    zSCSIBusID = item.scsitargetid
    
    Set objPartitionSet = item.Associators_("Win32_DiskDriveToDiskPartition","Win32_DiskPartition")
    
    For each objPartition in objPartitionSet
      set ObjDriveSet = objPartition.Associators_("Win32_LogicalDiskToPartition","Win32_LogicalDisk")

      For each objDrive in objDriveSet
        If objPartition.bootpartition then
          zDrive = objDrive.Caption & " - Boot Partition"
        else
          zDrive = objDrive.Caption
        end if
        zVolume = objDrive.VolumeName
        
        zFileSys = objDrive.FileSystem
        zDriveSize = fFormatNum(objDrive.Size,false)
        zFreeSpace = fFormatNum(objDrive.FreeSpace,false)
        
        zSerialNumber = objDrive.VolumeSerialNumber
      next
    next
  next  
   
  set objDriveSet = nothing
  set objPartitionSet = nothing
  set objInstance = nothing
End Sub

A few disclaimers: This was taken from another program and had to be modified to fit in this context. The section you will be interested in is the last section with "zSerialNumber". There may be more than one partition. So this variable may be overwritten on each iteration. This would be best done with a array(a easy change to make). In the program it came from this was not necessary.

You will need to use a valid Administrator account for the script to work(local administrator works fine). You should NOT hard code the password, but to each his own.

This is assuming a win2k computer.

Hope this helped. Let me know if you need anything explained.

Roger
 
Thank you Roger for your help the routine was very helpful.
I want to ask my question in other manner:
I am preparing a website where my costumers will download a setup file, then after they run the program they will input a password to run my program, this password is based in the C drive serial Number of the customer PC, when he send me the number of his C drive serial Number (this must appear in the download page), then I can send him the combination number (the password) to input it and this will allow him to run the program. Is that possible in JavaScript?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top