How can I generate a UUID from the command line in Windows XP? Something like "uuid" or "uuidgen" in Linux.

link|improve this question

65% accept rate
feedback

3 Answers

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,"{",""),"}","")
link|improve this answer
1  
Funny how in Windows it's only unique to each planet, but in Unix and related systems it's unique throughout the entire universe. – Bratch Jun 23 '10 at 19:45
feedback

If powershell is installed this is a simple commandline to get a guid

powershell -Command "[guid]::NewGuid().ToString()"
link|improve this answer
feedback

From MSDN Library: Generating Interface UUIDs.

link|improve this answer
Do you know where I can download this "uuidgen" from? – Zubair Jun 23 '10 at 11:24
It comes with Visual Studio - I'd expect it to come with the express edition of Visual C++ which I believe is a free download, as well – Rowland Shaw Jun 23 '10 at 11:34
1  
msdn.microsoft.com/en-us/library/aa373930%28VS.85%29.aspx says that the uuidgen utility (Uuidgen.exe) is automatically installed when you install the Platform Software Development Kit (SDK). – Mehper C. Palavuzlar Jun 23 '10 at 11:35
Is it not available as a seperate download, as I have no use for the SDK or for Visual Studio. – Zubair Jun 23 '10 at 11:36
@Zubair: Install SDK, get uuidgen, uninstall SDK. Anything else is a copyright violation. – harrymc Jun 23 '10 at 11:48
show 4 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.