By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,308 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,308 IT Pros & Developers. It's quick & easy.

Who started me?

P: n/a
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.

Feb 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tom van Stiphout wrote:
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.

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.
Feb 28 '06 #2

P: n/a

"Tom van Stiphout" <no*************@cox.net> schreef in bericht news:6s********************************@4ax.com...

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?


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

Feb 28 '06 #3

P: n/a

"Tom van Stiphout" <no*************@cox.net> wrote in message
news:6s********************************@4ax.com...
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.

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()
Feb 28 '06 #4

P: n/a
On Tue, 28 Feb 2006 09:42:35 +0000 (UTC), "Anthony England"
<ae******@oops.co.uk> wrote:

Thanks guys. Lots of great suggestions.
-Tom.

"Tom van Stiphout" <no*************@cox.net> wrote in message
news:6s********************************@4ax.com.. .
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.

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()


Feb 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.