Guruprasad
Guruprasad

Reputation: 1445

Unable to use a set variable in batch file

Hi I have this code in my batch file

set destpath = "C:\"

copy help.txt %destpath%

pause

But I see that the command that gets executed while running the batch file is

copy help.txt

The batch file is not recognizing the 'destpath' variable at all. What could be the issue here?

Upvotes: 0

Views: 1111

Answers (2)

jcomeau_ictx
jcomeau_ictx

Reputation: 38412

don't use spaces: set destpath="C:\"

Upvotes: 1

René Nyffenegger
René Nyffenegger

Reputation: 40489

You should have no space before the equal sign. Try

set destpath=c:\

instead.

Upvotes: 2

Related Questions