Question

How would I get this code to store the value returned by uuidgen.exe? I want the value of guid to be a Guid, not the path to uuidgen.exe.

SET guid="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\uuidgen.exe"
ECHO %guid%
pause
Was it helpful?

Solution

In a batch file you need the double percent sign on your variables, and to properly quote the path to uuidgen.exe. The following works in a batch file on my local computer (note the different version of SDK)

for /f %%i in ('"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\uuidgen.exe"') do set guid=%%i
echo %guid%
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top