0

I've programmed Windows batch files for almost as long as Windows has been around and I've typically used:

set counter=0

However, I've been reviewing a legacy batch file and it has:

set "counter=0"

I know this is legal syntax according to ss64.cmd but are there any other benefits? The only one mentioned on ss64.cmd is that you don't get caught out by invisible trailing spaces.

1 Answer 1

1

As you indicate

 v There is a space here set data=0 set "data=0" Avoid spaces at the end of the variable 

But also

set data=^<^<^>^> set "data=<<>>" Include special characters without having to escape them 

which can solve things as

C:\Tests\Cloak & Dagger files>set folder=%cd% "Dagger" is not recognized as an internal or external command, operable program or batch file C:\Tests\Cloak & Dagger files>set "folder=%cd%" C:\Tests\Cloak & Dagger files>set folder folder=C:\Tests\Cloak & Dagger files 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.