@echo off
setlocal EnableExtensions EnableDelayedExpansion
title Wsamiaw HWID
chcp 65001 >nul 2>&1

REM Same HWID as Wsamiaw client / launcher — no Java required (PowerShell SHA-256).

set "DOCS=%USERPROFILE%\Documents"
if exist "%USERPROFILE%\Belgeler\" set "DOCS=%USERPROFILE%\Belgeler"
if not exist "%DOCS%" set "DOCS=%USERPROFILE%"

set "OUTFILE=%DOCS%\Wsamiaw-HWID.txt"
set "HWID="

for /f "usebackq delims=" %%H in (`powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  "$ver = [Environment]::OSVersion.Version;" ^
  "if ($ver.Major -ge 10 -and $ver.Build -ge 22000) { $os = 'Windows 11' }" ^
  "elseif ($ver.Major -ge 10) { $os = 'Windows 10' }" ^
  "else { $os = 'Windows ' + $ver.Major };" ^
  "switch ($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { $arch = 'amd64' } 'ARM64' { $arch = 'aarch64' } default { $arch = $env:PROCESSOR_ARCHITECTURE.ToLower() } };" ^
  "$user = $env:USERNAME;" ^
  "$sb = $os + '|' + $arch + '|' + $user;" ^
  "if ($env:PROCESSOR_IDENTIFIER) { $sb += '|' + $env:PROCESSOR_IDENTIFIER };" ^
  "$bytes = [Text.Encoding]::UTF8.GetBytes($sb);" ^
  "$hash = [Security.Cryptography.SHA256]::Create().ComputeHash($bytes);" ^
  "$hex = -join ($hash | ForEach-Object { $_.ToString('x2') });" ^
  "Write-Output $hex.Substring(0, 32)"`) do set "HWID=%%H"

if not defined HWID (
  echo.
  echo  Could not compute HWID ^(PowerShell required^).
  echo.
  pause
  exit /b 1
)

(
  echo Wsamiaw HWID
  echo =============
  echo.
  echo !HWID!
  echo.
  echo Paste this 32-character value on the account page with your license key:
  echo https://wsamiawclient.lol/account.html
  echo.
  echo Same algorithm as the client ^(.wsam hwid^) and Wsalauncher.
  echo Saved: %DATE% %TIME%
) > "%OUTFILE%"

echo.
echo  HWID: !HWID!
echo.
echo  Saved to:
echo  %OUTFILE%
echo.

set /p OPEN=Open in Notepad? [Y/N] 
if /i "!OPEN!"=="Y" start "" notepad "%OUTFILE%"

exit /b 0
