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.
For discussions of all Approximatrix products and related software
You are not logged in. Please login or register.
Approximatrix Forums → User Support → 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.
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.
Approximatrix Forums → User Support → Any possibility to extract BIOS & HDD serial number?
Powered by PunBB, supported by Informer Technologies, Inc.