Generate GUID in Windows with batch file

The Windows SDK comes with a tool called uuidgen (if you have Visual Studio, you'll have the Windows SDK, and you need to run the Visual Studio Command Prompt to set proper paths).

C:\>uuidgen

This will output a new GUID, e.g.

cc23b318-156e-473f-aa6e-517bf091a0f0


Try this if you have powershell environment.

FOR /F %a IN ('POWERSHELL -COMMAND "$([guid]::NewGuid().ToString())"') DO ( SET NEWGUID=%a )

Then ready Guid value from %NEWGUID%


1.Create a file named myuuid.vbs with the content

set obj = CreateObject("Scriptlet.TypeLib")  
WScript.StdOut.WriteLine Mid(obj.GUID, 2, 36)

2.goto command prompt

cscript //NoLogo myuuid.vbs

Using JAVA code

    UUID uuid = UUID.randomUUID();
    String randomUUIDString = uuid.toString();

easy to do in powershell

[guid]::NewGuid()