Schtasks Permission Error on Administrative User? [closed]
Asked Answered
L

4

10

I know this has been asked in different ways a few times, but nothing has helped me for my specific case.

This is all done on a Windows 7 Home Premium desktop computer through Windows Command Line. I was attempting to create a simple batch program using schtasks to open a bunch of programs automatically upon my logon. However, when I attempt to create the task it says that the access is denied for my batch file.

    schtasks /create /tn Startup /tr "C:\ComputerStartup.bat" /sc onlogin
    ERROR: Access is denied.

So I tried to give my authentication (I am running this as an administrator user).

    schtasks /create /s Jackson-HP /u Jackson /sc onlogon /tn Startup /tr C:\ComputerStartup.bat

It prompted for a password for my user. I don't have a password for my computer so I just pressed enter, and it said:

    ERROR: User credentials are not allowed on the local machine.

I'm not sure how to fix this. I'm still new to creating batch files, so I may be making a newbie mistake. I appreciate any help you can give, thanks.

Lysimachus answered 18/2, 2013 at 1:19 Comment(5)
is the user Jackson a member of the admin group ? Can you try to specify your computername before the username like /u mycomputername\JacksonGangway
I tried that, but that's invalid syntax. The only user for the computer (my home computer) is Jackson, who is an admin in the system.Lysimachus
did you ran the command from an elevated dos prompt ?Gangway
I just ran the command from cmd, so no? I will try that, but alas I know not of what that is.Lysimachus
Locate Command Prompt in All Programs\Accessories, right click it and choose Run as administrator – that'll give you a command prompt with elevated rights. (The window title will (should) then also read Administrator: Command Prompt.)Ekg
D
11

Try using an elevated (admin) command prompt and use the /ru command-line switch instead of the /u one. Use /rp if you want to specify the password as well.

Duffer answered 12/7, 2013 at 21:20 Comment(4)
This is correct, TechNet says "The /u and /p parameters are valid only for changing a task on a remote computer". If you're not changing the password, you can just use /RP [password] to avoid being prompted to the passwordExocentric
/ru and /rp don't work with /delete. You need to run the script as an administratorGroves
Shoot, I forgot to mark this answer as accepted oh so long ago. My apologies.Lysimachus
Better late than never! Thanks!Duffer
B
1

I know it is an old issue here, but no solutions out there, and I found out that it strictly is a bug in schtasks.exe

I found a weird workaround/trick, using the Hosts. file(!) though.

See https://eskerahn.dk/wordpress/?p=2724

I only tried it with /Query, but would be surprised if it did not handle the other ones as well.

Someone somewhere seems to have had the (wrong) idea that you would never need to access your local machine with higher credentials than what you are logged in with interactively.

Bethanie answered 7/11, 2018 at 14:38 Comment(1)
I wonder why this was immediately downvoted by someone? The suggestion of elevation and removal of credentials suggested in previous posts is also just a workaround, and not a solution...Bethanie
S
1

I had this issue and solved it by recreating the scheduled task (via export and import). It seems that if the user running it is not the "author" of the task then it will throw the access denied error

Saccharine answered 16/4, 2019 at 1:58 Comment(0)
L
0

This is an old question, so you've probably figured it out or moved on, but my understanding is that schtasks won't work with an account that has no password.

Leghorn answered 26/8, 2016 at 18:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.