|I have a batch file I am writing and I have a mid level understanding of MS-DOS. This batch file is going to be part of a startup script for a program to check for new versions on a server, if a new version exists rename the old file (code below) using the file version. Then it will copy the new version from the server and launch the program. |
I have everything working right, and was able to rename files using %date% but decided using file version was a better route. However I'm stuck trying to get it to work properly from the batch file. It works fine from a CMD prompt, but fails in a batch file.
I can get the following code to work in a CMD prompt... it works perfectly!
FOR /F "tokens=1-11 delims= " %g in ('filever ^"C:\Program Files\GE\Start Stop\Start Stop Dryer.exe^"') DO REN "C:\Program Files\GE\Start Stop\Start Stop Dryer.exe" "Start Stop Dryer%k.exe"
But when I edit it and add the double % to use in a batch file.....
FOR /F "tokens=1-11 delims= " %%g in ('filever ^"C:\Program Files\GE\Start Stop\Start Stop Dryer.exe^"') DO RENAME "C:\Program Files\GE\Start Stop\Start Stop Dryer.exe" "Start Stop Dryer%%k.exe"
The batch file doesn't run. It hangs up for about 30-60 secs then I get a never ending scroll of "The syntax of the command is incorrect". It never ends, and even a CTRL C to terminate doesn't work. I have to close the CMD window without the batch file completing.
I've used this forum for a lot of advice to write my entire script, so I thought I'd post this one up and see if someone can help?