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?
GetMACAddress.pyInstallDir "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
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")