7

I am trying to write a scheduled task that will run in the context of the currently logged in user.

It appears there was an option to run the task as a group in Windows 7 (see https://superuser.com/questions/656964/what-user-must-a-scheduled-task-run-as-in-order-to-be-visible-for-all-users), but this option is not present in Windows 10:

enter image description here

How can I achieve this in Windows 10?

Ben
  • 1,137
  • 9
  • 26
  • 44
  • Could it be the fact that you are running on Windows 10 Home Edition? On my Windows 10 Pro, I have the option to "Change User or Group" – jcrossbeam May 19 '16 at 09:24
  • @jcrossbeam - No, I'm on Win10 Enterprise :-( – Ben May 19 '16 at 09:25
  • And do you have local admin rights on the user currently logged on with? You could perhaps run `Task Scheduler` as Administrator, and see if that makes a difference. – jcrossbeam May 19 '16 at 09:31
  • Unfortunately I need this to run as the currently logged in user (who will not have admin privileges) as the task is designed to log information about whoever is currently logged in. – Ben May 19 '16 at 09:32
  • 1
    I see, but that is what the `Change User or Group` is for, which context the task will run in. The user creating the task still probably needs admin rights to be allowed to create tasks for other users. If you create the task as admin, but assign the group you want it to run as, I think you will get the results you want. – jcrossbeam May 19 '16 at 09:35
  • Sure - but the problem I have is that I can't assign it to a group, only to a user. If you compare the image above (mine) to the Windows 7 one in the link above, you'll see the button on Win7 says "change user or group" and the one on Win10 just says "change user". (Even if I go into object types the only available object type is "Users") – Ben May 19 '16 at 09:37
  • I understand what you mean, but if you have the ability to run the task scheduler as administrator, you will be able to `change user or group`. I just tried this on my own PC. With a normal user, you can only `Change User`, but with admin right, you can change both – jcrossbeam May 19 '16 at 09:41
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/39998/discussion-between-ben-and-jcrossbeam). – Ben May 19 '16 at 09:43

1 Answers1

8

If you run Task Scheduler as Administrator, the option to Change User or Group will be available. There you can set the task itself to run as a non-privileged group.

jcrossbeam
  • 260
  • 2
  • 13
  • 4
    I have this option on the scheduler: "When running the task use the following user account". How to set it to the current user please? – Ali123 Feb 02 '20 at 06:47
  • 5
    @Ali123 I had the same doubt and I found that setting the "user account" to not be an user but instead to be the group itself named `users` worked for me. See here: https://superuser.com/a/656966/559711 – Pedro A Sep 28 '21 at 02:01
  • I'd like to note that the use case of the [first comment](https://superuser.com/a/656966/443147) (application should only start once per user) doesn't play well with `Users`, as the app will start for all logged in users simultaneously. – tresf Dec 13 '22 at 21:22