.net-core - 如何在批处理文件中运行 .net 核心应用程序
问题描述
我正在编写一个 .net 核心应用程序作为同步数据的作业运行。我已将 dotnet.exe 命令添加到 Path,当我直接在命令行中运行应用程序时,它运行良好。
我已经将应用程序部署到服务器并编写了一个批处理脚本(job.bat)来运行它,如下所示。
cd D:\the\folder\where\the\app\locate
dotnet TheJobToBeExecuted.dll
我想每 5 分钟运行一次作业,所以我使用下面的脚本将批处理添加到任务计划程序
schtasks /create /tn "Job" /tr "D:\the\folder\where\the\batch\locate\job.bat" /sc minute /mo 5
但这项工作并没有按预期工作。然后我如下更改job.bat以查看发生了什么。
cd D:\the\folder\where\the\app\locate
dotnet TheJobToBeExecuted.dll
pause
消息显示如下
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
但是我已经安装了 dotnet 并将其添加到服务器上的路径中,我也可以直接在服务器 cmd 上运行该应用程序。
我错过了什么吗?谢谢。
解决方案
推荐阅读
- transition - 非齐次连续时间马尔可夫模型中沿给定固定状态路径的转移概率,例如 s1->s2->s3?
- c# - C#:在类库中等待用户输入而不冻结图形用户界面
- design-patterns - SwiftUI - 应用商店评级部分,设计克隆
- lotus-notes - 要运行此代理,您必须至少选择一个文档
- c++ - 如何在 qt5 中使用 OpenCV 视频捕获获取树莓派相机中的最新帧?
- java - 如何检查 Connector/J 代码是否过期?
- c++ - 无法在基于范围的循环中修改引用的值
- php - 添加PHP透明层
- swift - 如何在 onSubmit 块中使用 swift await 函数
- c - 有多个文件时如何定义宏?