可以/为什么硬盘序列号会改变 [英] Can/Why Does A Hard Drive Serial Number Change
问题描述
我们的反盗版软件根据用户的硬盘序列号来识别他们.我相信这是一个不变的功能,除非用户更改他们的主要物理驱动器,否则不会改变 - 如果我错了,请纠正我?我们使用WMI
python 模块来获取用户的硬盘序列号.
Our anti-piracy software identifies people according to their Hard Drive Serial. This I believe is a constant feature and will not change unless the user changes their primary physical drive - correct me if I am wrong? We use the WMI
python module to obtain the users Hard Drive Serial Number.
对于我们的 2 台测试计算机,硬盘序列号已更改.但是我们根本没有更换他们的硬盘.
For 2 of our test computers the Hard Drive serial number has changed. But we haven't changed their hard drive at all.
什么会导致这样的问题?我们的代码是否在 Windows 操作系统中不全面?我确实注意到这个帖子提到了你如果标准用户进程检索序列号,则可能会得到错误的序列号.但在我们的例子中,管理员用户也发生了错误.
What could cause such a problem? Is our code that identifies the serial not comprehensive across windows operating systems? I did notice that this post mentions you can get the wrong serial if a standard user process retrieves the serial no. But in our case the error has occurred on an admin user aswell.
一些重要信息:
- 这两个测试节点都运行 Windows 8 Professional
- 一台电脑是东芝笔记本电脑
- 另一台电脑是 Acer Iconia 平板电脑
- 平板电脑最近从 Windows 8 更新到 Windows 8.1,我注意到此更新后序列号发生了变化
- 笔记本电脑的管理员用户遇到了此问题.平板电脑有一位遇到此问题的标准用户.
硬盘序列号是硬件设备的MAC地址还是其他什么?
获取硬盘序列号的代码:
Code to obtain the Hard Drive Serial number:
c = wmi.WMI()
for item in c.Win32_PhysicalMedia():
if "PHYSICALDRIVE" in str(item.Tag).upper():
serialNo = item.SerialNumber
break
一个简短的脚本,它以正常进程和提升/管理进程的形式检索用户硬盘序列号.
A short script that retrieves a users Hard Drive Serial number as a normal process and as an elevated/admin process.
注意: 对我来说,无论作为用户还是管理员,它都会输出完全相同的序列号.这个脚本对你也有同样的作用吗?
Note: For me it outputs exactly the same serial number no matter as a user or as a admin. Does this script do the same for you aswell?
import os
import sys
import wmi
import win32com.shell.shell as shell
ASADMIN = 'asadmin'
def get_elevated_privleges():
if sys.argv[-1] != ASADMIN:
script = os.path.abspath(sys.argv[0])
params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)
def get_hard_drive_serial():
c = wmi.WMI()
for item in c.Win32_PhysicalMedia():
if "PHYSICALDRIVE" in str(item.Tag).upper():
return str(item.SerialNumber)
return None
print "HD Serial as Regular User: " + get_hard_drive_serial()
get_elevated_privleges()
print "HD Serial as Admin User: " + get_hard_drive_serial()
推荐答案
我知道这是一个旧线程,但我刚刚遇到了同样的问题,使用驱动器的序列号作为密钥.我认为最好在某处记录我的发现.
I know this is a bit of an old thread, but I have just had the same issue, using the drive's serial number as a key. I thought it would be good to document my findings somewhere.
我注意到的一件事是,在 Windows 7 和 Windows 8.1 之间,WMI 例程返回驱动器序列号的方式似乎发生了变化.
One thing I noticed was that somewhere between Windows 7 and Windows 8.1, there seems to have been a change in how the WMI routines return the drive serial number.
我屏蔽了一些字符.
Windows 10 reports: [S21D********04F]
Windows 8.1 reports: [S21D********04F]
Windows 7 reports: [2SD1********40 F]
W7 及以下似乎没有对驱动器信息进行字节交换.
It seems that W7 and below are not byte-swapping the drive info.
这篇关于可以/为什么硬盘序列号会改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!