473,770 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"differenti ate 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 2239
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.comwrot e in message
news:11******** **************@ 51g2000cwl.goog legroups.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
"differenti ate 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.comwrot e in message
news:11******** **************@ 51g2000cwl.goog legroups.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
"differenti ate 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.publi c.dotnet.framew ork
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.comwrot e in message
news:11******** **************@ 51g2000cwl.goog legroups.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
"differenti ate 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
9674
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 application (AA.exe) to Task Scheduler by using another application (say BB.exe), which is also developed using VB6? The operating systems can be Windows 2000, Windows XP or any later version of Windows... We also wish that whenever the second...
19
5825
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 name in the Command Prompt. Has anyone used the Windows Task Scheduler to run .py scripts, and if so isthere some intracacy to it? Is there a more UNIX version of a cron program one can run on Windows? Has anyone written a simple cron...
11
4087
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 in the Task Scheduler for Windows? Basically I'm after something that'll allow me to specify a "recurring" or "once off" schedule with advanced options like "the first monday in the month" etc.
4
2295
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, just like clicking from Control Panel -> Scheduled Task -> Add Scheduled Task. Appreciate ahead for any of your suggestions. Thanks.
2
14446
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 command (if there is, please let me know). So the next option would be to write a small .net program that would do it and run that via task scheduler. How would you mute the volume in code in the vb.net program? I'm not quire sure where to get...
8
1585
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 from my table and I loop through this until a match is made and then I run another program. Since I am continously checking the system for a specific time the CPU stays at 99 %. I tried adding a do loop and a timer to try to slow down the time...
2
4176
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. The application is supposed to pull some report data and make a webservice call to sent out this data.
17
2713
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 Main something like Sub Main() MainForm.showdialog
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.