9

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.

Rezkin
  • 441
  • 1
  • 6
  • 17
  • is the user Jackson a member of the admin group ? Can you try to specify your computername before the username like `/u mycomputername\Jackson` – Loïc MICHEL Feb 18 '13 at 08:58
  • 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. – Rezkin Feb 18 '13 at 16:08
  • did you ran the command from an elevated dos prompt ? – Loïc MICHEL Feb 18 '13 at 16:22
  • I just ran the command from cmd, so no? I will try that, but alas I know not of what that is. – Rezkin Feb 18 '13 at 21:45
  • 1
    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`.) – Andriy M Feb 19 '13 at 08:26

4 Answers4

10

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.

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
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

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

Eske Rahn
  • 1,137
  • 12
  • 11
  • 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... – Eske Rahn Nov 07 '18 at 14:46
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

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.

ncooper09
  • 113
  • 10