Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralRe: Static event preventing instance subscriber from disposing. Pin
DaveyM698-Mar-09 8:56
professionalDaveyM698-Mar-09 8:56 
GeneralRe: Static event preventing instance subscriber from disposing. Pin
harold aptroot8-Mar-09 9:15
harold aptroot8-Mar-09 9:15 
AnswerRe: Static event preventing instance subscriber from disposing. Pin
N a v a n e e t h8-Mar-09 16:35
N a v a n e e t h8-Mar-09 16:35 
QuestionFiltering in BindingSource of a generic List Pin
jaypatel5128-Mar-09 5:42
jaypatel5128-Mar-09 5:42 
AnswerRe: Filtering in BindingSource of a generic List Pin
Mycroft Holmes8-Mar-09 12:35
professionalMycroft Holmes8-Mar-09 12:35 
GeneralRe: Filtering in BindingSource of a generic List Pin
jaypatel5128-Mar-09 20:34
jaypatel5128-Mar-09 20:34 
QuestionAutomatic mailing list filter by parameters from database [an architecture problem] Pin
aviadqwerty8-Mar-09 5:33
aviadqwerty8-Mar-09 5:33 
Questionrunning tastk/application on shutdown [modified] Pin
fabgar8-Mar-09 3:39
fabgar8-Mar-09 3:39 
Hi, I am working on a task scheduler. Apart from scheduling tasks, daily, weekly, etc .. I would also like to let them run at login, but more importantly before the system shuts down.

I tried several methods already:

(1) by trying to intercept the shutdown and starting the application. At the moment it works but sadly the writer of this example code mentioned himself that it's not that trustworthy. It doesn't always work. So that’s not the best solution.
private void PreventShutdown()
        {
            SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
        }

        private void SystemEvents_SessionEnding(Object sender, SessionEndingEventArgs args)
        {
            if (args.Reason == SessionEndReasons.SystemShutdown)
            {
                args.Cancel = true;
                //... do someting 
            }
        }

(2) by using the group policy settings, and placing a script file (task.bat) in the "windows\system32\grouppolicy\machines\scripts\schutdown" folder + a scripts.ini in the ... scripts folder. (apparently you can't access these GP, scripts settings programmatically)

If you do this manually (gpedit.msc) it works, but if you generate the files in code and place them in the appropriate folders it doesn't.

Can anyone help me with this problem. Is there anyone that has some experience with this, knows other ways to achieve my goal or maybe tell me what I'm doing wrong ?

Any help/suggestions much appreciated.

Thanx

modified on Sunday, March 8, 2009 8:57 PM

AnswerRe: running tastk/application on shutdown Pin
fabgar9-Mar-09 8:03
fabgar9-Mar-09 8:03 
QuestionLocation of page on the printpreview control Pin
baranils8-Mar-09 2:47
baranils8-Mar-09 2:47 
Questionexporting a Drown chart in Owc11 Pin
reza assar7-Mar-09 23:49
reza assar7-Mar-09 23:49 
Questionfacing error in calling a com component from code? Pin
sailesh_gupta7-Mar-09 23:04
sailesh_gupta7-Mar-09 23:04 
Questionhow to convert web page to image file using c# in .net Pin
vinodkrebc7-Mar-09 21:33
vinodkrebc7-Mar-09 21:33 
AnswerRe: how to convert web page to image file using c# in .net Pin
Xmen Real 7-Mar-09 23:23
professional Xmen Real 7-Mar-09 23:23 
GeneralRe: how to convert web page to image file using c# in .net Pin
vinodkrebc8-Mar-09 18:05
vinodkrebc8-Mar-09 18:05 
Questionneed help [modified] Pin
YiXiang_897-Mar-09 21:20
YiXiang_897-Mar-09 21:20 
AnswerRe: need help Pin
ABitSmart7-Mar-09 23:27
ABitSmart7-Mar-09 23:27 
QuestionInvoking external application? Pin
zaki_82790257-Mar-09 19:33
zaki_82790257-Mar-09 19:33 
AnswerRe: Invoking external application? Pin
Ravi Bhavnani7-Mar-09 19:44
professionalRavi Bhavnani7-Mar-09 19:44 
AnswerRe: Invoking external application? Pin
sohighthesky8-Mar-09 4:39
sohighthesky8-Mar-09 4:39 
Questiondatagrideview Pin
sevda207-Mar-09 19:21
sevda207-Mar-09 19:21 
AnswerRe: datagrideview Pin
vinodkrebc7-Mar-09 21:42
vinodkrebc7-Mar-09 21:42 
QuestionRemoting in .NET 2.0 - still not getting it! Pin
caix7-Mar-09 16:30
caix7-Mar-09 16:30 
AnswerRe: Remoting in .NET 2.0 - still not getting it! Pin
aviadqwerty8-Mar-09 5:44
aviadqwerty8-Mar-09 5:44 
QuestionChange fore color of datetimepicker Pin
trinm19877-Mar-09 16:09
trinm19877-Mar-09 16:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.