Topic: Any possibility to extract BIOS & HDD serial number?

Hello guys

I m looking for a code to extract BIOS & HDD serial number (to string). Can anybody suggest?

Thank you.

Wrote on Thinkpad X220 i7-2620M, 16 MB RAM, 512 Samsung 830 SSD

Re: Any possibility to extract BIOS & HDD serial number?

If you're confident users have Windows Vista or higher, you can retrieve both using the wmic command.  An example Fortran program is below:

program serial
implicit none

    character(10), parameter::outfile = "serial.txt"
    
    character(len=40)::ignore, results

    call get_serial("diskdrive", outfile)
    
    ! Load in results
    open(unit=100, file="serial.txt", status="old")
    read(100, *) ignore
    read(100, *) results
    
    print *, "Hard disk serial #: ", trim(results)
    close(100)
    
    call get_serial("bios", outfile)
    
    ! Load in results
    open(unit=100, file="serial.txt", status="old")
    read(100, *) ignore
    read(100, *) results
    
    print *, "Bios serial #: ", trim(results)
    close(100)
    
    call unlink(outfile)
    
    contains
    
    subroutine get_serial(serialid, finalfile)
    implicit none    
    
    character(*), intent(in)::serialid
    character(*), intent(in)::finalfile
    
    character(128)::serialcmd
    
        serialcmd = "wmic "//&
                    trim(serialid)//&
                    " get serialnumber > unicode.txt && type unicode.txt > "//&
                    trim(finalfile)
        
        call execute_command_line(trim(serialcmd))
        
        call unlink("unicode.txt")
    
    end subroutine get_serial
end program serial

If you'll notice, I redirect the results of wmic to temporary file unicode.txt and then subsequently redirect it via "TYPE" to another final file.  The reason for this double-redirect is that the original output seems to be in a unicode format, but ASCII is so much easier to deal with when reading in results in Fortran.  Hence, I use the "TYPE" command, which should always generate pure ASCII.

Jeff Armstrong
Approximatrix, LLC

Re: Any possibility to extract BIOS & HDD serial number?

Try with WMIC commands

http://net-informations.com/q/mis/wmic.html

Macin