Getting Serial Number of the Hard Drive Provided by the manufacturer through PHP

后端 未结 9 664
时光取名叫无心
时光取名叫无心 2020-12-17 03:36

Getting Serial Number of the Hard Drive Provided by the manufacturer through PHP : How can it be done? I want to store it in a file.

OS : windows 2000,XP,ME,Vista.

相关标签:
9条回答
  • 2020-12-17 04:08

    Run the following with shell_exec (test in command prompt if needed):

    wmic path win32_physicalmedia get Tag,SerialNumber
    

    DISKDRIVE doesn't get the actual serial number for my drive that shows plugged in through an IDE channel. the above seemed to get the actual serial numbers for all of my drives. Tag will also return you what type of drive it is which may be helpful for identifying different drives.

    Example output:

    SerialNumber     Tag
    WD-WX55D33JQNZ4  \\.\PHYSICALDRIVE4
    S1OKIJNH938475   \\.\PHYSICALDRIVE0
    WD-CV44HJ5L765Y  \\.\PHYSICALDRIVE1
    WD-WX41D65SD1UU  \\.\PHYSICALDRIVE2
    WD-WXB1SD3OIJHG  \\.\PHYSICALDRIVE3
                     \\.\CDROM0
    
    0 讨论(0)
  • 2020-12-17 04:08

    Do you want the hard drive from the server or a client? PHP runs on the server so getting it straight from the client doens't seem possible to me.

    The manual suggest you can execute commands on you server: http://nl2.php.net/manual/en/ref.exec.php

    Unfortunately I don't enough Unix to get you hdd serials.

    0 讨论(0)
  • 2020-12-17 04:16
    hdparm -i /dev/sdX
    

    that's on linux, not sure on windows though. You could execute that via "system()"

    Have a look at http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.hk.msdn.connection&tid=e41f0af2-2e76-4be6-9b7b-636e79ac0491&cat=zh_HK_3b03d742-993a-4f96-accd-1063c6bfd559&lang=zh&cr=HK&sloc=&p=1

    Might be a way forward.

    Also, when I ran a "dir" on the command prompt, it shows:

    C:\Documents and Settings\Administrator>dir
     Volume in drive C has no label.
     Volume Serial Number is BC16-5D5F
    

    Is that what you're looking for?

    0 讨论(0)
提交回复
热议问题