GUID Generator - Console application

Console version of the program (GuidGen.exe) has very similar functionality as the Windows application, but can be used in batch files.

Usage: GuidGen.exe [-c NUM] [-f FMT|IND] [-l] [-s] [--wincompat] [-pf STR] [-sf STR] [-cp [ALL|FIRST]] [-h] [-V] [--home]

Mandatory arguments to long options are mandatory for short options too. Options are case-sensitive. Values are case insensitive. Options and values enclosed in square brackets are optional.

Available options:

Switch (Option)Description
-c, --count=NUM Number of GUIDs to generate. Default 1.
-f, --format=FMT|IND Desired GUID format name or index (see description below).
-l, --lower-case Display GUIDs in a lower case.
-s, --swap-bytes Reverse byte order in multi-byte members of the GUID structure (Data1, Data2, Data3).
--wincompat The first hex digit in the Data3 field = 4 (CoCreateGuid compatible).
-pf, --prefix=STR Text string that will be added at the beginning of each GUID.
-sf, --suffix=STR Text string that will be added at the end of each GUID.
-cp, --copy=[VAL] Copy generated GUID(s) to the clipboard.
Available values:
ALL - copy all generated GUIDs (default).
FIRST - copy only the first GUID.
-h, --help, /? Display help.
-V, --version Show application version.
--home Opens program home page in default browser.

Available formats:

Format nameIndexDescription
REG 0 32 digits separated by hyphens, enclosed in curly braces.
Example: {01020304-0506-0708-090A-0B0C0D0E0F10}
HexHCB 0 As above.
HexHSB 1 32 digits separated by hyphens, enclosed in square brackets.
Example: [01020304-0506-0708-090A-0B0C0D0E0F10]
HexHP 2 32 digits separated by hyphens, enclosed in parentheses.
Example: (01020304-0506-0708-090A-0B0C0D0E0F10)
HexH 3 32 digits separated by hyphens (default).
Example: 01020304-0506-0708-090A-0B0C0D0E0F10
Hex 4 32 digits without hyphens and braces.
Example: 0102030405060708090A0B0C0D0E0F10
URN 5 Example: urn:uuid:01020304-0506-0708-090A-0B0C0D0E0F10
Pascal 6 TGUID Pascal fields.
Example: $01020304,$0506,$0708,$09,$0A,$0B,$0C,$0D,$0E,$0F,$10
cstruct 7 GUID struct members.
Example: 0x01020304,0x0506,0x0708,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10
Delphi 8 Delphi interface identifier.
Example: ['{01020304-0506-0708-090A-0B0C0D0E0F10}']
OLE 9 Example: IMPLEMENT_OLECREATE(<<class>>,<<external_name>>,0x01020304,0x0506,0x0708,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10);
DEF 10 Example: DEFINE_GUID(<<name>>,0x01020304,0x0506,0x0708,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10);
ConstGUID 11 Example: static const GUID <<name>> = {0x01020304,0x0506,0x0708,{0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10}};
INT 12 GUID structure members converted to string, separated by hyphens. Data4 member is divided into two groups: 2 and 6-byte.
Example: 16909060-1286-1800-009010-011012013014015016
INT32 13 GUID structure interpreted as a sequence of four 32-bit unsigned integers.
Example: 16909060-117966086-202050057-269422093
HEX32 14 As above, only decimal numbers are converted to hexadecimal.
Example: 01020304-07080506-0C0B0A09-100F0E0D
INT64 15 GUID structure interpreted as a sequence of two 64-bit unsigned integers.
Example: 506660481424032516-1157159078456920585
HEX64 16 As above, only decimal numbers are converted to hexadecimal.
Example: 0708050601020304-100F0E0D0C0B0A09
INT128 17 128-bit unsigned integer. The real value of the GUID.
Example: 21345817372864405881775281973894447876
HEX128 18 INT128 converted to hexadecimal notation.
Example: 100F0E0D0C0B0A090708050601020304

Examples

Generating 10 GUIDs in Registry format:
    1. GuidGen.exe -c 10 -f reg
    2. GuidGen.exe --count=10 --format=reg
    3. GuidGen.exe -c=10 -f=0
Generating 10000 GUIDs in HexH format and saving them to GUIDS.txt file:
    GuidGen.exe -c 10000 -f hexh > GUIDS.txt
Generating 4 GUIDs in default format, with custom prefix and suffix:
    GuidGen.exe -c 4 --prefix="My prefix " --suffix=" My suffix"
Generating GUID in URN format in a lower case:
    GuidGen.exe --format=URN --lower-case
Generate one Delphi interface identifier and copy it to the clipboard:
    GuidGen.exe --format=Delphi --copy

Variables in batch files

If you plan to use the program in batch files, you will probably want to assign a GUID returned by the program to the variable. You can do this in two ways: using a temporary file or by using a FOR loop. If the text returned by the GUID Generator contains spaces, you must use the first method.

  1. Temporary file
    
    @echo off
    
    set ggcmd=GuidGen.exe --format=HexH --count=1
    
    set temp_file=_temp_file_%RANDOM%.txt
    %ggcmd% > %temp_file%
    set /p guid=<%temp_file%
    del %temp_file%
    
    echo guid=%guid%
    
    pause
    
    
  2. FOR loop
    
    @echo off
    
    set ggcmd=GuidGen.exe --format=HexH --count=1
    
    for /f %%i in ('%ggcmd%') do set guid=%%i
    echo guid=%guid%
    
    pause
    
    

Portability

The application (console version) does not use registry, does not reads/writes any files, does not alter any system settings, does not need to work any additional runtime libraries or frameworks.

You can copy executable file (GuidGen.exe) to USB drive, and run the program from that drive on other computers.