GUID - Generate in Windows

How to Generate a New GUID or UUID in Windows

information   Information
GUID (or UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else.

A GUID is represented as a 32-character hexadecimal string, such as {dcab32b8-e5ec-4f09-af89-44634bc7a04d}, and is usually stored in the form of a 128bit integer. It's nearly impossible for the numbers generated for the GUID to have two numbers repeated making them unique.

For more information about GUID, see:

This tutorial will show you how to quickly generate a new GUID (UUID) in XP, Vista, Windows 7, and Windows 8.

Note   Note
Windows 7 and Windows 8 comes with the PowerShell feature included.

In XP and Vista, you will need to download and install PowerShell.





OPTION ONE

To Generate a New GUID in PowerShell


1. Open PowerShell, copy and paste either command below, and press Enter.​
[guid]::NewGuid()
OR
[guid]::NewGuid().ToString()
2. The generated 32-character number will be the new GUID.​
PowerShell_GUID.png
PowerShell_GUID-2.png






OPTION TWO

To Generate a New GUID in Command Prompt



Note   Note
This option uses a PowerShell command in a command prompt, so you will still need to have PowerShell installed (XP and Vista).

If you like, you can also use the command below in a .bat or .cmd file.


1. Open a command prompt, copy and paste either command below, and press Enter.​
powershell -Command "[guid]::NewGuid()"
OR
powershell -Command "[guid]::NewGuid().ToString()"
2. The generated 32-character number will be the new GUID.​
Command_GUID-1.png
Command_GUID-2.png


That's it,
Shawn


 

Attachments

  • Services.png
    Services.png
    2.7 KB · Views: 272
Last edited:
Cool trick. PowerShell is capable of doing so many things!
 

My Computer

System One

  • OS
    Microsoft Windows
    Other Info
    I do the testing and give feedback on User Experience and ideas for Classic Shell.

My Computer

System One

  • OS
    Windows 8.0 x64
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satelite C55D-A Laptop
    CPU
    AMD EI 1200
    Memory
    4 gb DDR3
    Graphics Card(s)
    Raedon 340 MB dedicated Ram
    Monitor(s) Displays
    Built in
    Screen Resolution
    1366 x 768
    Hard Drives
    640 GB (spinner) Sata II
    Keyboard
    Built in
    Mouse
    Touch pad
Why would you want to do this though? Just for VMs?
 

My Computer

System One

  • OS
    Windows 10 Pro Prieview x64
    Computer type
    Laptop
    System Manufacturer/Model
    MacBook Pro Core2Duo
    CPU
    T7600
    Memory
    3
    Graphics Card(s)
    ATI Radeon X1600
    Monitor(s) Displays
    Internal
    Screen Resolution
    1440 x 800
    Hard Drives
    40GB
    Keyboard
    Apple
    Mouse
    Apple
    Internet Speed
    Varies
    Browser
    Various
    Antivirus
    Defender
Why would you want to do this though? Just for VMs?

Programmers use Guids much more than users. It avoids name collisions. For example I can create a named memory mapped file, or mutex, or semaphore. Programmers used to do stuff like make up names they thought would be unique. Example, MyVeryOwnUniqueSeamaphoreNamexxxxx. If someone else just happened to come up with the same name you could have 2 programs fighting over the resource. But if I use a Guid generator to make this name, MySemaphore88c1f6a9-e063-4e5c-8161-c824ac987896 then no other generated guid should produce the part after MySemaphore. I just stuck MySemaphore on there because kernel object names, iirc, are not supposed to start with a number but a character.
 

My Computer

System One

  • OS
    Windows 8.0 x64
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satelite C55D-A Laptop
    CPU
    AMD EI 1200
    Memory
    4 gb DDR3
    Graphics Card(s)
    Raedon 340 MB dedicated Ram
    Monitor(s) Displays
    Built in
    Screen Resolution
    1366 x 768
    Hard Drives
    640 GB (spinner) Sata II
    Keyboard
    Built in
    Mouse
    Touch pad
OK thanks - I was thinking of the HDD GUID which you have to change for VMs. This is more like a random number generator for the strings we see in DCOM etc then if I understand you correctly.

EDIT: I am a programmer actually but on IBM i not windows. There you make up names for objects and are confined to 10 characters and only one directory level (well sort of). Guess what - you do get duplicates. Think how many programmers when writing a payroll program and confined to 10 characters will call it "PAYROLL". Almost all of them do.
 

My Computer

System One

  • OS
    Windows 10 Pro Prieview x64
    Computer type
    Laptop
    System Manufacturer/Model
    MacBook Pro Core2Duo
    CPU
    T7600
    Memory
    3
    Graphics Card(s)
    ATI Radeon X1600
    Monitor(s) Displays
    Internal
    Screen Resolution
    1440 x 800
    Hard Drives
    40GB
    Keyboard
    Apple
    Mouse
    Apple
    Internet Speed
    Varies
    Browser
    Various
    Antivirus
    Defender
Yeah, Guid was created for COM/DCOM stuff. Depending how they are used sometimes they are called CLSID or whatnot. ActiveX is a good example. In Windows there's an associative array object for scripting named Scripting.Dictionary. But in the registry the name is associated with a CLSID.

And yeah I can believe over 90% named it PAYROLL. :) That's like the old unix linkers that only had 6 character names. Linux is still burdened with the short program names for standard commands as a legacy.
 

My Computer

System One

  • OS
    Windows 8.0 x64
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satelite C55D-A Laptop
    CPU
    AMD EI 1200
    Memory
    4 gb DDR3
    Graphics Card(s)
    Raedon 340 MB dedicated Ram
    Monitor(s) Displays
    Built in
    Screen Resolution
    1366 x 768
    Hard Drives
    640 GB (spinner) Sata II
    Keyboard
    Built in
    Mouse
    Touch pad
Hello Dragon Drop,

Yes, you could assign a GUID to open a folder when referenced. For example, you would reference the GUID when adding a folder or item to This PC or Control Panel.

What did you have in mind? :)
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
I mean, if I've created a new GUID and I want it to represent a certain folder, how do I TELL Windows which folder I want it to represent? Do I have to create a new Registry key or something?
 

My Computer

System One

  • OS
    64-bit Windows 8
    System Manufacturer/Model
    HP 23-D030
Yep, it would involve manually adding the GUID and other keys to the registry for this.

What were you wanting to do this for the folder with the GUID? It all depends for what you may need to do in the registry. There may also be an alternative for the folder.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
In all my experimenting with Windows, I've had occasion to use GUID's in several ways. But what I was thinking of at the moment was the special kind of shortcut links that you can create by using a GUID in the folder name. They create "expanding menus" when used in a toolbar. But you can only do that with a folder that has a GUID. An ordinary folder shortcut won't expand into a menu.
 

My Computer

System One

  • OS
    64-bit Windows 8
    System Manufacturer/Model
    HP 23-D030
Well, here's an example of my E:\Images folder being referenced to a GUID in the registry to help. This would be the .reg file to add it for this.

Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{bcf54cb8-7ae3-4fa6-9ec5-573ef99f9912}]
@="[COLOR=#ff0000][B]Folder Name[/B][/COLOR]"

[HKEY_CLASSES_ROOT\CLSID\{bcf54cb8-7ae3-4fa6-9ec5-573ef99f9912}\Shell\Open\Command]
@="explorer [COLOR=#ff0000][B]E:\\Images[/B][/COLOR]"


Once added, here's an example of a shortcut target using the GUID to open the folder.


explorer.exe shell:::{bcf54cb8-7ae3-4fa6-9ec5-573ef99f9912}
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
For some reason, the "Command" subkey wasn't getting any value. I fixed it by typing the value into the Registry myself, and now the GUID works when used as in your example.

Unfortunately, it still doesn't work the way I hoped it would -- i.e. when used in a folder's name to create a link. I've noted before that some GUID's work that way and some don't, though I still don't understand why. Anyway, thanks for your assistance. :)
 

My Computer

System One

  • OS
    64-bit Windows 8
    System Manufacturer/Model
    HP 23-D030
Anytime. Is there any way to use the normal full path of the folder as the target of a shortcut for what you were wanting to do?
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
In general, regular shortcuts are fine. But when you have a toolbar, like that one I designed with many items in it for that other tutorial, a shortcut won't open into a cascading sub-menu in the toolbar, unless it's the special kind of shortcut that I used there, made with a folder name like "AdminTools.{d20ea4e1-3957-11d2-a40b-0c5020524153}" and so on. I was hoping that kind of folder name would work with a GUID that I created, but it apparently doesn't.
 

My Computer

System One

  • OS
    64-bit Windows 8
    System Manufacturer/Model
    HP 23-D030
Back
Top