Sunday, 28 September 2008

Batch file variables

Admitedly, I'm not a big batch file geek but like most of you I infrequently dive in and whip up a batch file for any number of reasons. 

So with that preface, here's my stupid tip: 

When setting a variable, don't included spaces between the assignment operator

This probably isn't what you want:

set myvar = hello
echo %myvar%
%myvar%

But this works as expected:

set myvar=hello
echo %myvar%
hello

No comments:

Post a Comment

Spam comments will be deleted

Note: only a member of this blog may post a comment.