Link to home
Create AccountLog in
Avatar of oyvindell
oyvindell

asked on

Check for files/directories before the program start

I have a program that I want to publish in a Citrix Farm, but this program needs to have it`s configuration files under each user homedir/appata.

If some configuration is changed, I dont want to copy these files into each userdir manualy, but would like a visual basic or other commands to check the shared configuration folder first, and if a newer file there, it should be copied over to the userdir/appdata directory.

Any ideas?
Avatar of mdougan
mdougan
Flag of United States of America image

We used a scheme to check for program updates, where when the application first started up, it would make an HTTP request to a web server on the Company's intra-net.  We had information there about the latest release etc, and the program could download the updates if there were some (it checked file versions between what was on the client and what was on the webserver).

You could do something similar... if the config file on the server was newer than the one in the client's area, then download and overlay the clients.  Then read from the config file.
Avatar of oyvindell
oyvindell

ASKER

I forgott to mention that the config files is just ordinary .ini files in plain text, and not new msi or exe files that runs. So what`s needed is more like a file copy function
Not really... if you do an HTTP Get or Post, even if the file type that you are linking to in the URL is a .INI or a .TXT or whatever, the HTTP request will get the file and download it to your program.  It will then be necessary for the program to parse what it retrieved, but that is pretty easy.

In our application, the information we got back was in .XML format, which makes the parsing easier, as you can load it into a DOM object, and then query the different attributes easier.
I need a simple solution that I can go live with. Im not a programmer, but in my words, the example would be :

Program.bat <- file they start to start the program
Check if directory m:\documents and settings\userdir\appdata\program exist, if not create it
Check if files xxx in m:\documents and settings\userdir\appdata\program  exist, if not copy them for \\severname\share\program
Pause
Start Program m:\program files\program\program.exe
Well, now you're giving conflicting specs as compared to your initial post, where you stated that you might change the configuration from time to time, so, needed to look at whether files on the server are newer than those on the client, which is a little more complicated to do with a batch file.

Adding the code to your program would be fairly easy, depending on what language your program is written in, but that assumes that you can modify the source of your "program.exe".  If not, then some sort of batch command file is your best bet.  I can help you with the source code, but not the batch command code, if that is the direction you eventually decide to take.
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I have used a similar application.

I basically had two applications to run, first was my "startup.exe".  It checks ini information on the local installation and compares it to ini information in the "master" location.  If there is a difference, the user is prompted to update local installation.  (Of course, this step may be omitted and an update forced).  The startup.exe handles all the checking and copying.  This way, I don't have to contend with any file locks.

After the copy is complete, or if there are no changes to copy, the main executable is launched.

Hope this helps some.

Regards,
Sekans