Another issue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jreat
Posts: 7
Joined: 09 Sep 2009 14:32

Another issue

#1 Post by jreat » 11 Sep 2009 09:50

I have another batch file I am trying to get working. All I am really trying to do is check a version on a flash drive then update it to the latest version. For some reason it closes before hitting the pause. I have the pause in there to help trouble shoot. Any suggestions?

cls
@echo off
cd sbusb
@echo ----- This is not ready to be used Please close by using RED X ------
@echo.
@echo What drive letter is your flash drive?
set /p dr=
copy %dr%:\version.txt H:\ITM03\Programs\BootDisk\
type version.txt> %ver%
pause
if '%ver%'=='378' goto 379
if '%ver%'=='379' goto 380
if '%ver%'=='380' goto 381
if '%ver%'=='381' goto 382
if '%ver%'=='382' goto 383
if '%ver%'=='383' goto 384
if '%ver%'=='384' goto 385
if '%ver%'=='385' goto 386
if '%ver%'=='386' goto 387
if '%ver%'=='387' goto 388
if '%ver%'=='388' goto 389
if '%ver%'=='389' goto end
:378
:379

and so on

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 11 Sep 2009 10:38

%ver% is not defined.

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#3 Post by avery_larry » 11 Sep 2009 10:39

I think you want this:

for /f %%a in (version.txt) do set ver=%%a


not this

type version.txt>%ver%

jreat
Posts: 7
Joined: 09 Sep 2009 14:32

#4 Post by jreat » 11 Sep 2009 11:06

what does the %%a mean / do?

So I just removed the % signs and it works. The type is setting ver. Or at least seems to be.

type version.txt> ver

jreat
Posts: 7
Joined: 09 Sep 2009 14:32

#5 Post by jreat » 11 Sep 2009 12:37

ok so it is closer. The program stays open but it is not going to the correct spot. it runs 378 then 379. I want it to jump to the correct version. I tried what you suggested Larry but that did not work either :(

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#6 Post by avery_larry » 11 Sep 2009 14:37

jreat wrote:what does the %%a mean / do?

http://ss64.com/nt/for.html
So I just removed the % signs and it works.
It doesn't work -- it just continues on but doesn't do what you want.
The type is setting ver. Or at least seems to be.

type version.txt> ver
No, it's not setting a variable. It's redirecting the output of the type command into a file called "ver".

You probably have to add the drive letter to make it work:

Code: Select all

for /f %%a in (%dr%:\version.txt) do set "ver=%%a"


To see what ver gets set to you can:

echo %ver%

If it's not working, you can remove the @echo off and perhaps see more of what's happening. Otherwise you may have to post your version.txt file to see if it's the problem.

jreat
Posts: 7
Joined: 09 Sep 2009 14:32

#7 Post by jreat » 14 Sep 2009 09:51

That works great now. Thank you so much for your help. And thank you for the link that describes what they do.

Post Reply