Imthedude025

Create Random GUIDs (Batch)

Feb 5th, 2021
12
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @if (@X) == (@Y) @end /* JScript comment
  2. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. ::Create Random GUIDs Via Batch ::
  4. ::Created by D.RUSS#2430 [http://russdev.mooo.com/] ::
  5. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6. @title Create Random GUIDs
  7.  
  8. :GenerateNewGUID
  9. @echo off
  10. for /f "tokens=*" %%a in ('cscript //E:JScript //nologo "%~f0" "%~nx0"') do (
  11. if "%~1" equ "" (
  12. echo %%a
  13. ) else (
  14. set "%~1=%%a"
  15. )
  16. )
  17. %my_uuid%
  18. echo ==Press Enter For New GUID==
  19. pause >nul
  20. echo(
  21. goto :GenerateNewGUID
  22. @if (@X)==(@Y) @end JScript comment */
  23.  
  24. UUIDv4 =
  25.  
  26. function b(
  27. a // placeholder
  28. ){
  29. return a // if the placeholder was passed, return
  30. ? ( // a random number from 0 to 15
  31. a ^ // unless b is 8,
  32. Math.random() // in which case
  33. * 16 // a random number from
  34. >> a/4 // 8 to 11
  35. ).toString(16) // in hexadecimal
  36. : ( // or otherwise a concatenated string:
  37. [1e7] + // 10000000 +
  38. -1e3 + // -1000 +
  39. -4e3 + // -4000 +
  40. -8e3 + // -80000000 +
  41. -1e11 // -100000000000,
  42. ).replace( // replacing
  43. /[018]/g, // zeroes, ones, and eights with
  44. b // random hex digits
  45. )
  46. }
  47.  
  48. WScript.Echo(UUIDv4());
RAW Paste Data