[英]Task Scheduler Create Task DotNet not working
I am trying to schedule a task using Task Scheduler on Windows. 我正在尝试使用Windows上的任务计划程序来计划任务。 It is for a console app written with .net Core. 它是用.net Core编写的控制台应用程序。 I have created a task, set a trigger and created a new action. 我创建了一个任务,设置了一个触发器并创建了一个新动作。
When I manually run it, I get a 'Last Run Result' of 'The system cannot find the file specified. 当我手动运行它时,我得到的“上次运行结果”为“系统找不到指定的文件”。 (0x80070002)' . (0x80070002)” 。 I have ensured that the user account running the task has access to the database on SQL Server. 我已确保运行任务的用户帐户可以访问SQL Server上的数据库。
I ran it in the command line as dotnet "C:\\Program Files\\UTDT_Database_Update\\publish\\UTDT_Database_Update.dll" and it worked successfully. 我在命令行中以dotnet“ C:\\ Program Files \\ UTDT_Database_Update \\ publish \\ UTDT_Database_Update.dll”的身份运行了它,并成功运行了。
My 'Edit Action' is as follows. 我的“编辑操作”如下。
Program/Script: dotnet 程序/脚本: dotnet
Add arguments (optional): UTDT_Database_Update.dll 添加参数(可选): UTDT_Database_Update.dll
Start in (optional): C:\\Program Files\\UTDT_Database_Update\\publish\\ 开始于(可选): C:\\ Program Files \\ UTDT_Database_Update \\ publish \\
I haven't found any solutions that work yet. 我尚未找到任何可行的解决方案。 Anyone have any ideas? 有人有想法么?
Solution was to create a batch file (.bat) that contained the following: **@ECHO OFF dotnet "C:\\Program files\\UTDT_Database_Update\\publish\\UTDT_Database_Update.dll" ** 解决方案是创建一个包含以下内容的批处理文件(.bat):** @ ECHO OFF dotnet“ C:\\ Program files \\ UTDT_Database_Update \\ publish \\ UTDT_Database_Update.dll” **
Program/Script: UTDT_Database_Update_batch.bat 程序/脚本: UTDT_Database_Update_batch.bat
Add arguments: empty 添加参数: 空
Start in: Location of .bat file 开始于: .bat文件的位置
This made it run. 这使其运行。 Still not sure why original task didn't work but this at least gets it to run. 仍然不确定为什么原始任务不起作用,但这至少可以使它运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.