run task when user is not logged on

I have an old vb6 application that creates scheduled tasks. The tasks are set as run under a user account even when the user is not logged on. This works in Windows 2003 server, but the Windows 2008 server always sets the option "Run only when user is logged on", which I see as incorrect. The code creating the task is attached.
I found out that to control the option, I need to add (or remove) " + &H2000" to the mJob.Flags, and adding/removing this works fine on Windows 2003. Windows 2008 seem to ignore this.
Any ideas?

Set mJob = gSchedule.CreateTask(Name)
    mJob.ApplicationName = "xxxx.exe"
    mJob.Creator = "Created by " & UserName & " using " & App.FileDescription & " at " & Now
    mJob.Flags = tfDisabled + tfInteractive 
    mJob.WorkingDirectory = App.Path
    mJob.CommandLine = "Job-" & mNumber
    mFilename = App.Path & "\" & mJob.CommandLine
    With mJob.Triggers.Add
        .TriggerType = ttDaily
        .BeginDay = Now
        .StartTime = Now
    End With

Open in new window

mbrutvanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Justin OwensITIL Problem ManagerCommented:
mbrutvan,
I sent this Question to a Moderator to ask them to add it to a couple of VB Zones for you.
Justin
0
mbrutvanAuthor Commented:
thanks
0
DanRollinsCommented:
Vista (and presumably Server 2008) use the new version of the TaskScheduler Interface.  There is a VB example here
http://msdn.microsoft.com/en-us/library/aa383665(v=VS.85).aspx 
and the documentation is quite comprehensive.  There's also a codeProject article that includes a wrapper... might save you some time:
http://www.codeproject.com/KB/cs/tsnewlib.aspx?msg=2470961
One thing you might try is executung the command-line utility:
SCHTASKS
http://msdn.microsoft.com/en-us/library/bb736357(VS.85).aspx
The /IT and /NP options affect actions when the user is logged off.
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbrutvanAuthor Commented:
SCHTASKS helps, thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.