How to differentiate between a program launched manually and launched by a windows task scheduler ??

M

mayur_hirpara

Hi,
I am writing a VB.NET application. It is a Windows application at the
moment.
The application contains a button. the click event of button perform a
long running task.
It needs to be started by windows task scheduler to carry out some
operation.

When I am testing the application I want to differentiate if the
"differentiate between a program launched manually and launched by a
windows task scheduler" so that in the load event of form I can call
the function which carries out long running task when application is
started by scheduler OR else if it ws launched manually then nothing
will happen automatically. USer will have to click the button to
perform the operation.

Again can someone show me ....
How to differentiate between a program launched manually and launched
by a windows task scheduler ???

Any help is greatly appreciated....
Thanks in advance,
--Mike.
 
P

Phil Wilson

If you're the one adding the program to the Task Scheduler, can't you just
add a command line option?

BTW do you mean the Scheduled Tasks feature or the AT command?
 
M

Michael M.

The only things I can think of is using a command line switch such as

Program.exe /autostarted

You could then add that to the Applications Windows Text

Me.Text = "Program Name" & Switch value.

You could then use the API function getWindowText to retrive it

Another way is to write the programs PID process Id to the registry with
this same cmd line switch and the second program reads it

Lastly you could use Custom Windows API Messages to query the process using
SEND MESSAGE API

Or, actualy, why not rename the second application and have two files?


All of the above assume that I am that you are writing the program that will
be scheduled though.
 
M

mayur_hirpara

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top