Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Who started me?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom van Stiphout - 28 Feb 2006 05:24 GMT
I have a "Launcher" application that does version checking. It will
copy a newer version from the server if needed, and then start the
main application. I believe Tony Toews "Auto FE Updater" serves a
similar purpose. My app calls ShellExecute to run the command line
specified in a "Launcher.ini" file. A typical command line may be:
AppCommandLine="C:\Program Files\Microsoft
Office2003\OFFICE11\MSACCESS.EXE" C:\Test\Test.mde
This all works fine. The path to MsAccess is typically there because
my users often have more than one version installed.

Now I want to know if my application was started by Launcher, or by
some other way. I would then refuse to run. My first idea was to add:
/x LaunchedByLauncher
to the command line. This macro would call a function that would set a
global variable, which I could test for in my startup code.
Alas, /x runs too late: the AutoExec macro runs first, then the /x
macro runs.

So I'm open to suggestions. How can I know who started me?

One thought is to keep Launcher.exe running a bit longer (currently it
is start-and-terminate), and then call FindWindow to see if it is
running. Seems like a cumbersome process and technically I would not
be 100% sure that instance of Launcher started Me.

Thanks,

-Tom.
salad - 28 Feb 2006 06:56 GMT
> I have a "Launcher" application that does version checking. It will
> copy a newer version from the server if needed, and then start the
[quoted text clipped - 24 lines]
>
> -Tom.

Maybe create the existence of a file when something is launched...or
with a particular name.  When the shelled program launches, check for
the existence using Dir.  Set some flags in your opening form and then
delete the file.
Arno R - 28 Feb 2006 09:15 GMT
> Now I want to know if my application was started by Launcher, or by
> some other way. I would then refuse to run. My first idea was to add:
[quoted text clipped - 5 lines]
>
> So I'm open to suggestions. How can I know who started me?

Salad gave you a good idea: You can have your launcher create some file.
But I would only delete (and force a delete...) this file when the app ends.
That way you can not only control 'who' launched your app, but also prevent the app to be started more than once from the same workstation.

Or: don't show anything on screen until your /x macro has run.
Show your mainform only from the /x macro
Or: kill the app with a timer event on a hidden form when your /x macro has not run

Arno R
Anthony England - 28 Feb 2006 09:42 GMT
>I have a "Launcher" application that does version checking. It will
> copy a newer version from the server if needed, and then start the
[quoted text clipped - 24 lines]
>
> -Tom.

If your app is launched by an exe then nobody can see the command line with
which the exe launched the app.  So you could specify a command-line option
using /cmd and pick this up with the Command function.
Because both the exe and the mde application are compiled, then you could
hard-code this secret code in both applications, effectively proving whether
or not launcher.exe was used or not.

Here is an example:

The shortcut might be:
"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" "C:\Demo\Demo.mdb"
/cmd "SecretCode"

Then your AutoExec macro has just one step:  RunCode with
function=DoStartup()

You have a module 'modStartup' with the following function in it:

Public Function DoStartup()

   Dim strCommand As String

   strCommand = Command()

   If StrComp(strCommand, "SecretCode", vbBinaryCompare) = 0 Then
       MsgBox "Launched by launcher", vbInformation
   Else
       MsgBox "Not launched by launcher", vbCritical
       Application.Quit
   End If

End Function

This approach allows you to check this value at any point once the database
is open, so there is no need to use a global variable.  For example, a
button's OnClick event could be MsgBox Command()
Tom van Stiphout - 28 Feb 2006 14:14 GMT
Thanks guys. Lots of great suggestions.
-Tom.

>>I have a "Launcher" application that does version checking. It will
>> copy a newer version from the server if needed, and then start the
[quoted text clipped - 61 lines]
>is open, so there is no need to use a global variable.  For example, a
>button's OnClick event could be MsgBox Command()
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.