C# - How to list Scheduled Tasks for a specific user with the TaskSchedular Class

前端 未结 3 1417
半阙折子戏
半阙折子戏 2021-01-14 03:31

I was wondering if someone could help me, I am trying to list Scheduled Tasks from a specific user (Admin) on the local computer using the TaskScheduler Class (http://www.co

相关标签:
3条回答
  • 2021-01-14 04:18

    i doubt you can do this. windows tasks will be common for all the users please correct me if im wrong. but you can get the created user of the perticuler task or els you will be able to get the execution user of the particuler computer.

    but this will be differ when it comes to diffrent OS. such as windows 7 windows xp.

    0 讨论(0)
  • 2021-01-14 04:28

    This only works for tasks created and configured for Windows 2003, XP, Windows 2000.

    If you select for Windows 7, Windows 2008 or Windows Vista, Windows 2008 the jobs don't get stored with a .job extension in the C:\Windows\Tasks directory. They get stored in C:\Windows\System32\Tasks directory with no file extension and in XML format.

    The DLL fails to retrieve those configured for Windows 7, Windows Vista, Windows 2008.

    0 讨论(0)
  • 2021-01-14 04:32

    There doesn't seem to be a way to specify a user name when performing the query (only a machine name), but you can filter the results yourself using the Creator property:

    foreach (string taskName in st.GetTaskNames()) {
        using (Task task = st.OpenTask(taskName)) {
            if (task.Creator == "username") {
                listBox1.Items.Add(taskName);
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题