How can I generate a UUID from the command line in Windows XP?
How can I generate a UUID from the command line in Windows XP? Something like "uuid" or "uuidgen" in Linux.
If powershell is installed this is a simple commandline to get a guid
powershell -Command "[guid]::NewGuid().ToString()"
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,"{",""),"}","")
You can also use this command in a command prompt: wmic path win32_computersystemproduct get uuid
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 ...
Now in powershell, you can use built in New-GUID
function:
For /f "tokens=* delims= " %%a in ('powershell -noP -c "& {(New-GUID).GUID}"') do set "GUID=%%~a"