Skip to content
⌘ NSIS Forum Archive

Hard Drive Serial Number Is Different When NSIS Calls Script

2 posts

gretty#

Hard Drive Serial Number Is Different When NSIS Calls Script

Hello All 🙂

I have a very weird error occurring. I have a Python script that prints out the user's Hard Drive serial number.

If I run this script in idle (or simply double click the script) it prints out my Hard Drive serial number as: 09sd01u4ctzn.

BUT If my NSIS installer runs that same Python script it prints out my Hard Drive serial number as: 90ds104utcnz. Ie, each 2 characters are reversed (instead of `09`, its `90` and so on).

Do you know why this is happening?

Some important information:

- The NSIS installer runs with elevated privileges (Admin)
- My laptop is 64 bit
- I am using Python 2.7
- If I run the Python script (through Idle) with elevated privileges it still prints out the same serial no. (`09sd01u4ctzn`) so I dont think elevated privileges is the cause.
- Maybe the cause is that WPython.exe is run as UTF-8 (or non-ascii)?
- Maybe the NSIS installer is 64 bit which affects the interpretation of the serial no.?

So I've tested a simple NSIS script and python script. The NSIS script calls the python script using `EXECWAIT`. As you can see the serial no. is different when the script is called by NSIS than if it is called by itself OR though a C# program (I've tested that also).

Any ideas what on earth is going on?

	InstallDir  "abc"
Name "def"
OutFile "def.exe"

Section
DetailPrint "Hello World"
ExecWait '"cmd.exe" /k' # Then type GetMACAddress.py in cmd (make sure python script is in same dir as the installer)
SectionEnd
GetMACAddress.py

    import wmi
c = wmi.WMI()
for item in c.Win32_PhysicalMedia():
if "PHYSICALDRIVE" in str(item.Tag).upper():
print item.Tag + ", " + item.SerialNumber

raw_input("Pause")
Afrow UK#
Are you using the x64 NSIS build? Is the Python script being run using the x64 or x86 runtime (or which do you have installed)?

Stu