473,419 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

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

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
3 2214
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Faiz | last post by:
We have developed an application in VB6 (say AA.exe). We wish to schedule the execution of this application (AA.exe) through Windows Task Scheduler. Is there a way through which we can add this...
19
by: Eric | last post by:
I'm trying to have some scripts run periodically on Windows XP and found the "Task Scheduler" did not execute my scripts. My scripts are of the form scriptName.py, and will run just by invoking that...
11
by: Codemonkey | last post by:
Hi, I am writing an App in .Net that involves some scheduling of tasks. I was wondering if anybody has come accross any components or examples of how to implement a schedule manager like the one...
4
by: Christina | last post by:
Dear All, How can I pop up the windows task scheduler inside of my .net application? Such as I have a button called Schedule Now, after clicking it, the Add Scheduled Task window will pop up,...
2
by: Bob Day | last post by:
Using VS 2003, VB. Net, MSDE... Usining task sheduler, I wish to mute the volume in the .bat file that task scheduler runs (windows XP Pro). I don't see anyway to do this via a .bat line...
8
by: Gordon | last post by:
Hi; I have designed a vb.net program that reads a dateTime value from a database table and then compares it to Now() through dateTime.compare(). I have loaded an array with my datetime values...
2
by: kplkumar | last post by:
Hi all I am fairly new to windows scheduler. I have an .exe console application that needs to be run 1st of every month. I created a scheduled task in Windows Schduler and called the .exe. ...
17
by: LittleRob | last post by:
I'm having problems using Windows Task scheduler (or AT or SCHTASKS) to run a VB.NET program unattended. I'm able to reduce it to some really simple code that still fails My program has a Sub...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.