Log who ran a scheduled task

G

Guest

Hello,

I am writing an exe that is intended to be run via a scheduled task.
However, I also need the flexibility to have users run the scheduled task
manually (right click task and select run). In the event a user runs the
task manually I need to verify their identity for logging purposes. So I
have two questions:

1. Is there a way to tell if a scheduled task was run because of its
scheduled time or if a user manually initiated it? I would prefer not to
hard code the scheduled time as a check, but rather see who has initiated the
run... i.e. NT Authority\system or MyDomain\MyUser.

2. As a follow-on to question to #1, is there a way to tell who initiated
the scheduled task to run? When the task is run manually, using
WindowsPrincipal the user always shows up as NT Authority\system (the user
that the task runs as).

Any help here would be appreciated!

Thanks,
Cory
 
L

Luke Zhang [MSFT]

Hi Cory,

Why do you need to have the user run the application from scheduled task
manually? Instead, you may have them run from a shortcut on desktop, or
command line, in this way the application can tell who has initiated it,
i.e. NT Authority\system or MyDomain\MyUser. So, I think a better
deployment strategy may help on the issue.

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top