[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 667
  • Last Modified:

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

0
mbrutvan
Asked:
mbrutvan
  • 2
1 Solution
 
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
 
mbrutvanAuthor Commented:
SCHTASKS helps, thanks
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now