windows 管理用户的 Schtasks 权限错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14928165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:17:18  来源:igfitidea点击:

Schtasks Permission Error on Administrative User?

windowsbatch-filepermissionscmdwindows-task-scheduler

提问by Rezkin

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.

这一切都是通过 Windows 命令行在 Windows 7 Home Premium 台式计算机上完成的。我试图创建一个简单的批处理程序,使用 schtasks 在我登录时自动打开一堆程序。但是,当我尝试创建任务时,它说我的批处理文件被拒绝访问。

    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 Hymanson-HP /u Hymanson /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.

我不知道如何解决这个问题。我对创建批处理文件还是个新手,所以我可能犯了一个新手错误。感谢您提供的任何帮助,谢谢。

回答by gonzobrains

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.

尝试使用提升的(管理员)命令提示符并使用 /ru 命令行开关而不是 /u 开关。如果您还想指定密码,请使用 /rp。

回答by ncooper09

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.

这是一个老问题,所以您可能已经想通了或继续前进,但我的理解是 schtasks 不适用于没有密码的帐户。

回答by Eske Rahn

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

我知道这是一个老问题,但没有解决方案,我发现它严格来说是 schtasks.exe 中的一个错误

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

我发现了一个奇怪的解决方法/技巧,使用主机。文件(!)虽然。

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

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

我只用 /Query 尝试过,但如果它也不能处理其他的,我会感到惊讶

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....

某些 * * CENSORED * * 某处似乎有(错误的)想法,他们永远不需要使用比交互式登录的凭据更高的凭据访问本地计算机....

回答by Sam Parslow

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

我遇到了这个问题并通过重新创建计划任务(通过导出和导入)解决了它。似乎如果运行它的用户不是任务的“作者”,那么它会抛出访问被拒绝的错误