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.showdi alog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event
doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog
for that machine.
Why is this so hard, when VB6 can do this no problem?
Thanks
Rob 17 2713
On which statements does it fail ?
IMO it is caused more likely by the execution context rather than by some
VB6 vs VB.NET issue. For example an application that would try to use the
printer under a service account could fail as in this case the user profile
is not loaded and sop there are no default printers available...
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de
news: 5r************* @mid.individual .net...
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.showdi alog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event
doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog for
that machine.
Why is this so hard, when VB6 can do this no problem?
Thanks
Rob
Patrice wrote:
On which statements does it fail ?
IMO it is caused more likely by the execution context rather than by some
VB6 vs VB.NET issue. For example an application that would try to use the
printer under a service account could fail as in this case the user profile
is not loaded and sop there are no default printers available...
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de
news: 5r************* @mid.individual .net...
>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.showd ialog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog for that machine.
Why is this so hard, when VB6 can do this no problem?
Thanks
Rob
Patrice
Thanks for the reply, but it doesn't fail on any of my code.
I added some logging:
1. Logging in the Sub Main() is OK
2. Logging in the form's New() is OK
3. Logging in the FormLoad event never gets executed.
It seems to me that I just can't show a form (using .ShowDialog) if the
code is to run from a scheduler, but I can't be the only person out
there with this problem. Well actually I know I'm not as I do get some
hits when I Google, but only a few, and never with a workaround.
Thanks
Rob
"LittleRob" <gr************ *@greymouse.co. ukschrieb
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.showdi alog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad
event doesn't. I then get a System.InvalidO perationExcepti on in the
Eventlog for that machine.
Why is this so hard, when VB6 can do this no problem?
I tried it and it works without an error. Are you logged-in when the task
starts? If you are not, it is not possible. You'd have to write a service
w/o a UI.
Armin
LittleRob wrote:
I'm having problems using Windows Task scheduler (or AT or SCHTASKS) to
run a VB.NET program unattended.
Sub Main()
MainForm.showdi alog
End Sub
Using ShowDialog on your /main/ form is a Bad Idea. Use ...
Application.Run ( New MainForm )
.... instead.
Without this, your form has no Windows Message loop to run in and so it
ends just as soon as it starts (which is probably why the Form's
constructor (sub New) is getting called but the Form is never loaded or
shown.
Also, if your application is running "unattended ", why is it showing a
Form (that no-one will be able to see or interact with)?
The Task Scheduler is a Windows Service which, generally speaking,
cannot display anything on screen. Indeed, showing a /dialog/
(typically a MsgBox) from a service /usually/ gets intercepted by
Windows and written to the Event Log instead!
HTH,
Phill W.
And what are the task parameters ? Do you have an open session when this
tasks runs ? Under which account does it run ?
Basially the idea is that if you don't have any active desktop then the
application can't show a form... I'm not sure if a scheduled tasks with a ui
should be shown in the current user desktop if one is available ? You could
try using notepad for example to see how it reacts...
If you want to run a UI without any desktop this is just not possible. You
may want to explain what is the exact purpose of this application...
--
Patrice
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de
news: 5r************* @mid.individual .net...
Patrice wrote:
>On which statements does it fail ?
IMO it is caused more likely by the execution context rather than by some VB6 vs VB.NET issue. For example an application that would try to use the printer under a service account could fail as in this case the user profile is not loaded and sop there are no default printers available...
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de news: 5r************* @mid.individual .net...
>>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.show dialog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog for that machine.
Why is this so hard, when VB6 can do this no problem?
Thanks
Rob
Patrice
Thanks for the reply, but it doesn't fail on any of my code.
I added some logging:
1. Logging in the Sub Main() is OK
2. Logging in the form's New() is OK
3. Logging in the FormLoad event never gets executed.
It seems to me that I just can't show a form (using .ShowDialog) if the
code is to run from a scheduler, but I can't be the only person out there
with this problem. Well actually I know I'm not as I do get some hits when
I Google, but only a few, and never with a workaround.
Thanks
Rob
Patrice wrote:
And what are the task parameters ? Do you have an open session when this
tasks runs ? Under which account does it run ?
Basially the idea is that if you don't have any active desktop then the
application can't show a form... I'm not sure if a scheduled tasks with a ui
should be shown in the current user desktop if one is available ? You could
try using notepad for example to see how it reacts...
If you want to run a UI without any desktop this is just not possible. You
may want to explain what is the exact purpose of this application...
--
Patrice
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de
news: 5r************* @mid.individual .net...
>Patrice wrote:
>>On which statements does it fail ?
IMO it is caused more likely by the execution context rather than by some VB6 vs VB.NET issue. For example an application that would try to use the printer under a service account could fail as in this case the user profile is not loaded and sop there are no default printers available...
"LittleRob" <gr************ *@greymouse.co. uka écrit dans le message de news: 5r************* @mid.individual .net... 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.sho wdialog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog for that machine.
Why is this so hard, when VB6 can do this no problem?
Thanks
Rob
Patrice
Thanks for the reply, but it doesn't fail on any of my code.
I added some logging:
1. Logging in the Sub Main() is OK
2. Logging in the form's New() is OK
3. Logging in the FormLoad event never gets executed.
It seems to me that I just can't show a form (using .ShowDialog) if the code is to run from a scheduler, but I can't be the only person out there with this problem. Well actually I know I'm not as I do get some hits when I Google, but only a few, and never with a workaround.
Thanks
Rob
Patrice (and everyone else)
Thanks for your reply.
I understand that showing a form during an unattended session seems a
little odd, but my point is that I want to be able to run the same code
whether logged in or not. If I run my program interactively then I see a
progressbar and some IO. If I'm not logged in then that goes off into
the aether, but the program should still run.
I have re-written the code to run differently when I pass it a
commandline parameter its just a shame I need to do this.
The other issue is that VB6 could do this with no problems. So it seems
a backwards step that I have to code around this.
Rob
Armin Zingler wrote:
"LittleRob" <gr************ *@greymouse.co. ukschrieb
>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.showd ialog
End Sub
In MainForm the New() does execute, but code in the MainFormLoad event doesn't. I then get a System.InvalidO perationExcepti on in the Eventlog for that machine.
Why is this so hard, when VB6 can do this no problem?
I tried it and it works without an error. Are you logged-in when the task
starts? If you are not, it is not possible. You'd have to write a
service w/o a UI.
Armin
Armin
No I'm not logged in when it runs. I'm not even in the same postcode, if
you see my reply to Patrice you'll see why I'm a bit confused, and
disappointed in VB.NET
Thanks
Rob
Phill W. wrote:
LittleRob wrote:
>I'm having problems using Windows Task scheduler (or AT or SCHTASKS) to run a VB.NET program unattended.
> Sub Main() MainForm.showdi alog End Sub
Using ShowDialog on your /main/ form is a Bad Idea. Use ...
Application.Run ( New MainForm )
... instead.
Without this, your form has no Windows Message loop to run in and so it
ends just as soon as it starts (which is probably why the Form's
constructor (sub New) is getting called but the Form is never loaded or
shown.
Also, if your application is running "unattended ", why is it showing a
Form (that no-one will be able to see or interact with)?
The Task Scheduler is a Windows Service which, generally speaking,
cannot display anything on screen. Indeed, showing a /dialog/
(typically a MsgBox) from a service /usually/ gets intercepted by
Windows and written to the Event Log instead!
HTH,
Phill W.
Phil
Thanks for taking the time to reply. If you see my reply to Patrice
you'll see what I'm trying to achieve. It seems odd that this was so
easy in VB6 and so hard in VB.NET
Thanks
Rob
Armin Zingler wrote:
>
>If I run my program interactively then I see a progressbar and some IO. If I'm not logged in then that goes off into the aether, but the program should still run.
I have re-written the code to run differently when I pass it a commandline parameter its just a shame I need to do this.
No, it's a good solution.
Armin
I totally disagree with you. Having 2 pathways through the code and
needing 2 shortcuts installed on site is a recipe for disaster. What
would have been a good solution is the VB6 way of doing things.
So what if I display a form that nobody sees. It might look odd, but
does it matter?
Already today I ran interactively using the wrong method and of course I
sat there waiting for something to happen, which it was - invisibly.
I wonder if there is a way to tell in code what is going on.
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bart Simpson |
last post by:
Hi,
I want to control 'Scheduled Tasks' in Windows 2003 by python program.
But I couldn't find any Python module about win32 'Scheduled Tasks'.
I could find only Perl module about it. (see http://taskscheduler.sourceforge.net)
But, I want to control 'Scheduled Tasks' by python :)
Is there any python module about win32 'Scheduled Tasks'?
|
by: G |
last post by:
I am trying to duplicate the printing of a shortcut-print of an access
report in my NT Scheduled Tasks. I can now print the report manually
very easily by right-clicking on a shortcut to the access report and
then selecting print.
I tried placing the following in the scheduled task, but the ms access
‘97 help does not list /print as an option:
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"
"E:\dbsfolder\\sales.mdb" /print...
|
by: DFS |
last post by:
I have two nightly scheduled jobs at a client site - one at 2:00am and the
other at 5:00am
Both jobs launch Access 2003, log into the default system workgroup, open a
Access .mdb that collects data, then shuts down.
Except for the scheduled time and file paths, the job settings are
identical. The machine is password-protected, so when each job was created
the password was entered.
|
by: Max |
last post by:
I'm writing a program that needs to be able to create custom .job files
and add them to the scheduled tasks folder. What I'd like to know is,
what is the format of a .job file and how do I go about adding in all
the data so that the task could run correctly?
If that is something not so easy to do, then say I need a certain part
of my program to execute on a schedule... How do I go about writing some
internal scheduling routine that won't...
|
by: helpful sql |
last post by:
Hi all,
I want to write a .Net solution that I would like to run as a scheduled
task in windows. I am not going to need any user interface. What I don't
understand is what kind of project I need to create in Visual Studio for
this solution. Is it Console App, Windows App, Class Library or Windows
Service? Please help. Also any sample code would be helpful too.
Thanks in advance.
| |
by: Satish |
last post by:
Scheduled Tasks (.Net ) does not run when server is logged off (Windows
2003):
I have a .net executable (command line exe) which performs certain
business operations. I can run the program (scheduled or manually)
without a problem if I am logged in. But when i log off and and set it
up as a scheduled task using the Task Scheduler, I receive the
following error.
Event Type: Error
|
by: Tatter |
last post by:
I have a simple .NET 1.1 console application, written with Visual Studio .NET 2003, that needs to be run on a Windows XP system as a scheduled task. When run on its own, the program executes with no errors. When run as a scheduled task on a computer with debugging tools installed, it runs with no errors.
When run as a scheduled task on a computer with no debugging tools installed, namely the Windows XP system it is supposed to be run on, it...
|
by: Paulson |
last post by:
Dear Freinds
I want to make a program that acts as a reminder for the
users.I need to open up the Scheduled task wizard programmatically.If you
type Tasks in the run command the Tasks folder(ie. Scheduled Taks folder)
is opened,but what I want is to open the Add Scheduled Task wizard in it.Is
there any run command to do that?
Also if I am able to open the Scheduled Task wizard like this is
there any way by which I can...
|
by: Dean Slindee |
last post by:
Need to write a standalone application that processes data once per day.
Looking for the application program types available that would satisfy these
requirements:
Requirements:
1. Unattended processing that looks for rows in tables in a SQL Server
database that is updated in batch once per day via another company's daily
process. The newly added rows are selected based on a process date
parameter (see #4).
2. Cleans and reformats the...
|
by: ranjitw |
last post by:
I am running backup to .mdb file on a Windows 2003 server .
My issue is that when the program completed it still is in a "running" state when I highlight the icon for the scheduled task I have to manually stop the task in order for the next scheduled backup to run.
Is there a command line switch that I can use to force quit the program after it is completed or even if the job does not complete.
Thanks for your help in advance
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |