Discussion Locked

using a flag file in a batch

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I know this isn't really a Windows question, but there's no Dos subject.
I need to write a batch file that will check a flag file for a version number, compare it to a version on a server directory, and if it is older than the server I will need torun a separate executable.
Example...
C:\update.txt contains "1000",
F:\update.txt contains "1001",
so batch file runs F:\update.exe and also copies new update.txt file to C:
I know this is possible, but it's been a LONG time and I could use a hand.

3 replies

by daniel_macnish

The DOS command FOR will do this - specifically FOR /F. To get the exact parameters, try typing FOR /? at a command prompt. I don't think that this works with Win9x though, only NT and 2000. A quick run-through:

Use one FOR statement to set a variable equal to the first file's version.
Use a second FOR statement to set a variable equal to the second file's version.
Compare the two variables.
Perform an action based on the result.

Hope this helps.

by grbeckmeyer

Thanks, but this isn't quite what I need. I came up with simple solution, rather than check the contents of the file, I'll just use the filename as the flag, and instead of updating the flag file on a server I'll just update the batch file to look for the new filename.

This discussion is closed to new replies.