[dba-VB] CopyAndRun

jwcolby jwcolby at colbyconsulting.com
Wed Jan 25 13:48:54 CST 2012


You might remember my discussing a C# program I am writing which I call CopyAndRun (C&R).  It 
basically is a table driven method of copying one or more files from the network to the user's 
workstation and then executing the (access) application.  I use it for creating a directory and 
copying my libs and access apps to the user's local c: drive.

I use the following code to actually open the file:

         public void mExecuteFile()
         {
             //http://stackoverflow.com/questions/5831844/tracking-multiple-processes-at-same-time
             try
             {
                 System.Diagnostics.Process myProcess = new Process();
                 myProcess.StartInfo.FileName = pDestFileSpec;
                 myProcess.StartInfo.UseShellExecute = true;
                 Process.Start(pDestFileSpec);
             }
             catch (Exception)
             {
                 throw;
             }
         }

Basically this hands off opening the file to Windows to use File Associations to figure out how to 
open the file.  This works well except that Windows will not open the same Access container (same 
name) multiple times.  Some of the users like to keep the FE open a couple of times.  I worked 
around this by adding an incrementing number to the file name until the file name is not in use 
(open) and then copy to and use that file name.

The other problem is that as the FE opens, C&R is not "finished" until the login stuff finishes (in 
the FE).  This one took awhile to figure out what was up.  Apparently Process.Start does not return 
until Access' thread goes idle.  Sigh.  I have not found a workaround for that yet.

What that means is that the user cannot start multiple instances loading at the same time.  Start 
one, log in, start the next, log in, start the next etc.

Other than that, it seems to work very nicely, and the file association thing does allow Access to 
"just figure out" what program to use rather than my having to know the path to Access on each 
user's workstation.

I hope to call this one done.

-- 
John W. Colby
Colby Consulting

Reality is what refuses to go away
when you do not believe in it



More information about the dba-VB mailing list