This project has moved and is read-only. For the latest updates, please go here.

[vb.net] Doesn't work in XP

May 20, 2012 at 10:42 PM

Hello,

I am trying to use this library in my app. Here is the code I was testing:

            Dim ts As New TaskService()
            Dim td As TaskDefinition = ts.NewTask
            td.RegistrationInfo.Description = "Test"
            Dim dt As New BootTrigger
            dt.Repetition.Interval = TimeSpan.FromMinutes(20)
            dt.Delay = TimeSpan.FromMinutes(20)
            td.Settings.Hidden = True
            td.Triggers.Add(dt)
            td.Actions.Add(New ExecAction("notepad.exe", "C:\test.log", Nothing))
            ts.RootFolder.RegisterTaskDefinition("Test", td)

It's based on the provided example. It works well in Win 7 X64, I tried it on XP 32 and it didn't work. I am not sure why it's not working. Any help would be appreciated.

Thanks

May 21, 2012 at 2:27 PM

You must set dt.Repetition.Duration to a value larger than the Interval under XP. You should be getting an exception that says that. Everything else looks good.

May 21, 2012 at 3:45 PM
Edited May 21, 2012 at 3:46 PM

Thank you Dahall, yes I did actually, right after my post. I tried this:

Added:

dt.StartBoundary = DateTime.Now.AddMinutes(20)    ' Got from another thread with a similar issue
dt.Repetition.Duration = TimeSpan.FromDays(1)

I didn't get any errors, but the task still not added! Is there anything thing else need to be defined, in order to make work under XP.

May 21, 2012 at 5:04 PM

Adding 20 minutes to the StartBoundary doesn't do anything with a BootTrigger. I'd leave that out.

You have set the Hidden property to true. If you didn't get any errors, the task may have been created and is just not visible. Under XP, you can open a Command Prompt, go to the \Windows\System32\Tasks folder and look to see if the "Test" file exists when you do "dir /ah" to view hidden files.

May 21, 2012 at 5:57 PM

hi Dahall, Thanks for your replay. you're completely right. It was there but hidden. I removed the startboundary, it didn't make any difference.

The only issue now! It's not set right. if the same code is excuted under win 7 it will be triggered at start-up and then repeated every 20 min. In XP, it only starts up and it doesn't repeat. I am not sure if this option is supported under xp, but not sure.

May 24, 2012 at 1:55 AM

This may be a subtle difference of the BootTrigger between versions.