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.
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
.TriggerType = ttDaily
.BeginDay = Now
.StartTime = Now