0

I am generating a Guid in a batch file, then I need to wrap that Guid in curly braces. How do I do that?

for /f %%i in ('"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\uuidgen.exe"') do set guid=%%i

ECHO %guid%
pause

set guid = "{"%guid%"}"
ECHO %guid%

My solution doesnt seem to work. Any ideas?

1 Answer 1

2
set guid={%guid%}

As simple as that. Note that you shouldn't have spaces around the = (because your variable name would end in a space and its value would start with one) and quotes are included verbatim in the value unless you quote the complete argument to set by using set "foo=bar" but that isn't necessary here.

Sign up to request clarification or add additional context in comments.

2 Comments

facepalm Don't know how I screwed that up... Thanks!
You can do it directly in your for loop too, by the way: set guid={%%i}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.