C # - list of scheduled tasks for a specific user with the TaskSchedular class

I was wondering if anyone can help me, I am trying to list the scheduled tasks for a specific user (administrator) on the local computer using the TaskScheduler class (http://www.codeproject.com/KB/cs/tsnewlib.aspx) I have the following:

    // richTextBox6.Text = string.Join(Environment.NewLine, taskNames);
    private void button22_Click(object sender, EventArgs e)
    {
        listBox1.Items.Clear();
        string machineName = (@"\\" + System.Environment.MachineName);
        ScheduledTasks st = new ScheduledTasks(machineName);
        // Get an array of all the task names
        string[] taskNames = st.GetTaskNames();
        foreach (var taskName in taskNames)
        {
            listBox1.Items.Add(taskName);
        }

        st.Dispose();
    }

"@" \ "" Indicates that the local machine is the target, but can a user be added to it? (Since it only displays tasks that are in C: \ Windows \ Tasks when executed)

+3
source share
3 answers

, ( ), , Creator:

foreach (string taskName in st.GetTaskNames()) {
    using (Task task = st.OpenTask(taskName)) {
        if (task.Creator == "username") {
            listBox1.Items.Add(taskName);
        }
    }
}
+2

, Windows 2003, XP, Windows 2000.

Windows 7, Windows 2008 Windows Vista, Windows 2008, .job C:\Windows\Tasks. C:\Windows\System32\Tasks XML.

DLL , Windows 7, Windows Vista, Windows 2008.

+2

I doubt you can do this. Windows tasks will be distributed to all users, please correct me if I am wrong. but you can get a user created perticuler or els tasks, you can get a user running a specific computer.

but it will be different when it comes to different OS. e.g. windows 7 windows xp.

0
source

Source: https://habr.com/ru/post/1665144/


All Articles