Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for prodid.bat

(view source code of prodid.bat as plain text)

  1. @ECHO OFF
  2. ECHO.
  3. IF NOT [%1]==[] GOTO Syntax
  4. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  5.  
  6. :: Export registry tree to a temporary file
  7. START /WAIT REGEDIT /E "%Temp%.\test.dat" "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion"
  8. :: Read the required value from the temporary file
  9. FOR /F "tokens=1* delims==" %%A IN ('TYPE "%Temp%.\test.dat"') DO IF /I %%A=="ProductId" SET ProductID=%%B
  10. :: Remove the quotes
  11. IF DEFINED ProductID SET ProductID=%ProductID:"=%
  12. :: Delete the temporary file
  13. IF EXIST "%Temp%.\test.dat" DEL "%Temp%.\test.dat"
  14. :: Display the result
  15. SET ProductID
  16. :: Done
  17. GOTO:EOF
  18.  
  19. :Syntax
  20. ECHO ProdID.bat,  Version 1.00 for Windows NT 4 / 2000 / XP
  21. ECHO Display Windows' Product ID and store its value in an
  22. ECHO environment variable "ProductID"
  23. ECHO.
  24. ECHO Usage:  PRODID
  25. ECHO.
  26. ECHO Written by Rob van der Woude
  27. ECHO http://www.robvanderwoude.com
  28.  

page last uploaded: 2017-04-06, 13:33