Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
–
–
–
–
Drop the following code into a new file name uuid.vbs
set obj = CreateObject("Scriptlet.TypeLib")
WScript.StdOut.WriteLine obj.GUID
Then you can run it from the command line like so:
cscript //NoLogo uuid.vbs
This will work on pretty much any computer that has the Windows Scripting Host installed - which certainly includes anything later than Windows 2000, and probably includes 95/98/ME as well... though I don't have an instance handy to check.
If you need to remove the braces, replace the last line with this
WScript.StdOut.WriteLine Replace(Replace(obj.GUID,"{",""),"}","")
–
–
–
–
–
–
To copy a new GUID to the clipboard, use this command :
cmd /c powershell.exe -Command "[guid]::NewGuid().ToString()|Set-Clipboard"
You can run the command straight from the Start, Run dialog ( WinLogo + R ),
then use Ctrl+V to paste the generated GUID, which WILL also save it into your Run dialog history - aka if you use it often it will pop-up as suggestion there ...
I found that uuidgen.exe is present inside my C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64 directory, probably because of some components that I have installed along with Visual Studio.
So I simply added C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64 to my PATH and now it's easy to remember to type uuidgen like I'm used on macOS instead of having to remember a long command.
If the system OS does not have Windows SDK but does have a C compiler with mingw-w64 toolchain then compile this small program to generate random GUID. Imported functions are UuidCreate (rpcrt4.lib) to create random UUID and StringFromCLSID (ole32.lib) to convert UUID to wide string.
#include <Windows.h>
#include <stdio.h>
* int UuidCreate(GUID *id);
* int StringFromCLSID(GUID *id, wchar_t **str);
* Libraries: Rpcrt4.lib Ole32.lib
int main(void)
GUID id;
wchar_t *str = NULL;
UuidCreate(&id);
StringFromCLSID(&id, &str);
wprintf(L"%ls\n", str);
You can use the Windows Subsystem for Linux, eg install Ubuntu -
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)
$ uuidgen
(prints a uuid)