Wednesday, January 2, 2013

Fix "was unexpected at this time" and “not recognized as an internal or external command” when run batch script on Windows 7 64bit system

My company use DOS batch script to build project. We still need to maintain some legacy projects. When run the build script from legacy project on 64bit Windows 7 system, I saw error "xxx was unexpected at this time", then the building script exit.

I did some search online and found to change
set x=%path% to set x="%path%" will solve this issue.

But after the modification, i saw new error of "xxx not recognized as an internal or external command", the xxx can be as simple as cmd, ping

After quite some time of Googling, finally I found a solution, change all path contain Program Files (x86) to PROGRA~2 in the PATH environment variable. And that solved my problem.

I wrote it down and hope my experience can help other people facing similar issues.

No comments: