Solved

Check for files/directories before the program start

Posted on 2008-06-13
7
233 Views
Last Modified: 2011-09-20
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?
0
Comment
Question by:oyvindell
7 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 21780957
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.
0
 

Author Comment

by:oyvindell
ID: 21781000
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
0
 
LVL 18

Expert Comment

by:mdougan
ID: 21781274
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:oyvindell
ID: 21781883
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
0
 
LVL 18

Expert Comment

by:mdougan
ID: 21782531
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.
0
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 500 total points
ID: 21783048
From your description it seems as if you just want to make sure that the the files from your config folder get copied to the users system. How about just copying the config folder to the app folder this would keep the files up to date. Visual Basic
Option Explicit
 

Private Const FO_COPY               As Long = &H2

Private Const FOF_SILENT            As Long = &H4

Private Const FOF_NOCONFIRMATION    As Long = &H10
 

Private Type SHFILEOPSTRUCT

   hWnd        As Long

   wFunc       As Long

   pFrom       As String

   pTo         As String

   fFlags      As Integer

   fAborted    As Boolean

   hNameMaps   As Long

   sProgress   As String

 End Type
 

Private Declare Function SHFileOperationA Lib "shell32" ( _

    SHT As SHFILEOPSTRUCT) As Long
 

Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" ( _

    Destination As Any, _

    ByVal Length As Long)

        

Public Sub CopyDirectory( _

    ByVal FromDirectory As String, _

    ByVal ToDirectory As String)

    

    Dim SHT As SHFILEOPSTRUCT

    

    ZeroMemory SHT, Len(SHT)

    

    SHT.hWnd = 0

    SHT.wFunc = FO_COPY

    SHT.pTo = ToDirectory

    SHT.pFrom = FromDirectory

    SHT.fFlags = FOF_SILENT Or FOF_NOCONFIRMATION

    

    SHFileOperationA SHT
 
 

End Sub
 

Private Sub Form_Load()

    CopyDirectory "e:\configfiles", "e:\appfiles"

End Sub

Open in new window

0
 
LVL 1

Expert Comment

by:Sekans
ID: 21793665
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
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Citrix XenDesktop, gold image, VMware, vSphere.
Citrix XenDesktop 7.6 Citrix Policies Audio
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now