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

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

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

Jan 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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?
--
Phil Wilson
[Microsoft MVP Windows Installer]
<ma***********@hotmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
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.

Jan 5 '07 #2

P: n/a
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.
<ma***********@hotmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
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.

Jan 5 '07 #3

P: n/a
Hi,
I had also posted this question on following microsoft news-group
microsoft.public.dotnet.framework
One of the persons replied with a link to VB6 code that worked after a
little tweak to parameter types and return types.

However, I also found following links which seem to be equally
helpful...

http://www.csharpfriends.com/Forums/...x?PostID=27395

and

http://groups.google.to/group/micros...1da01e43c2ff49

Thanks,
--Mike


Michael M. wrote:
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.
<ma***********@hotmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
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.
Jan 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.