[dba-VB] CopyAndRun

Stuart McLachlan stuart at lexacorp.com.pg
Thu Jan 26 23:20:38 CST 2012


I just did a bit of playing with a call to ShellExecute which your System.Diagnostics.Process 
appears to be a wrapper for.

You only get one instance if you  set the Filename to yourMDB

However, you can open multiple instances of the same MDB if you set the FileName = 
MSAccess.exe and the Parameters = yourMDB.

Interestingly, I didn't need to put the path to MSAccess.exe in the ShellExecute() call even 
though it is not in my Path. Windows must be using the Registry to locate it.


-- 
Stuart

On 25 Jan 2012 at 14:48, jwcolby wrote:

> 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
> 
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
> 

--
Stuart McLachlan

Ph:    +675 340 4392 
Mob: +675 7100 2028
Web: http://www.lexacorp.com.pg



More information about the dba-VB mailing list