Solved

.NET GUI Application does not run using Task Scheduler when user is logged off

Posted on 2006-11-06
4
398 Views
Last Modified: 2008-01-16
I have a .NET GUI Application that runs successfully via Task Scheduler when I am logged in or the PC is locked but it does not work when I am logged off (PC is still running) I verified that a different app (console based) that simply deletes a DIR runs fine even when I am not logged in.

I know that the App. runs in invisible mode when run by Task Scheduler when the user is not logged in. Is it an issue if the GUI Application uses Button.PerformClick() to trigger certain application logic? The application also launches a broswer window if needed, would this be an issue?

Thanks in advance for your help.
0
Comment
Question by:mubeen76
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
qz8dsw earned 125 total points
ID: 17886711
hokies, I think I'm right on these assumptions,

Sounds like it would be alot better suited to be a service in XP and just have a timer based trigger.
However you have to realise you actually have no buttons, it has no gui or desktop to start on when you are logged off so no where to place it's form even though it's invisible. Using form based trigger then I would expect to fail.

Launching a browser would be much the same, it might be able to launch it, but wether it could interact with it the way you want is another thing entirely.

I used a service to interact with Word via ADO which works fine, A scheduled event just did not work for much the same reasons you are striking.
I had to give the service a proper username and password so it could load a profile to interect with.
Because it used network resources (Much like yours would be with a browser I'm assuming) it would need a valid username and password that could use the network. The localsystem account for a service although has full access to the local machine, it has totally no access to anything on the network.

I hope this helps.

Terry
 

0
 
LVL 15

Expert Comment

by:qz8dsw
ID: 17886722
Well, or you could re-write it not to depend on or use gui based triggers.
0
 

Author Comment

by:mubeen76
ID: 17890096
hmm.. thanks qz8dsw. Is there a way I can tell in my application if it required the Task Scheduler to login? The thing is I want the user to possibly interact with the UI when the Task runs when the user is logged in but have it run in console mode when the user is not logged in.

0
 

Author Comment

by:mubeen76
ID: 17893559
I found a way to test if the application is running in invisible mode. When I call ShowDialog it throws the exception below and I can hence infer the mode. Thanks!

System.InvalidOperationException: It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at CEASIRLoader.frmMainPage.frmMainPage_Load(Object sender, EventArgs e)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most of the time we are in fix when all of sudden our systems behave weirdly.  Such problems cost time and effort... so it's best to take some preventive actions so that we can avoid such issues or overcome such problems more easily. Preventive M…
If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question