0

How can I show the salted hash value of BIOS serial in inno setup wizard

wmic bios get serialnumber this command will give the BIOS serial. But don't know how to use that in inno setup.

I'm going to use this to generate password so in the same wizard there should be a password field as well

Thanks

HDTV
  • 3
  • 5
  • 1
    You are not the first to call wmic in Inno Setup, so you might get some ideas from https://stackoverflow.com/questions/52021365/parsing-output-of-wmic-in-inno-setup – Lex Li Sep 03 '21 at 17:48
  • See also https://stackoverflow.com/q/40762683/62576, which is a better example. – Ken White Sep 03 '21 at 17:51

1 Answers1

0

@LexLi is correct that there are already questions about reading wmic output into Inno Setup, for example: Parsing output of wmic in Inno Setup

But my answer there also says, that it is not easy, as wmic outputs UTF-16 and that it is better to use WMI API. See Is there a way to read the system's information in Inno Setup.

function InitializeSetup(): Boolean;
var
  WbemLocator, WbemServices, Bios: Variant;
  Query: string;
begin
  Result := True;
  WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  WbemServices := WbemLocator.ConnectServer('.', 'root\CIMV2');

  Query := 'SELECT SerialNumber FROM Win32_BIOS';
  Bios := WbemQuery(WbemServices, Query);
  if not VarIsNull(Bios) then
  begin
    Code := GetSHA1OfString(Trim(Bios.SerialNumber) + 'Salt');
    Log(Format('Code is [%s]', [Code]));
  end
    else
  begin
    MsgBox('Cannot get computer code', mbError, MB_OK);
    Result := False;
  end;
end;

The above code stores the hashed serial number into Code variable. You can then use it anywhere you like.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992