【问题标题】:c# exe throwing error only when run through task schedulerc# exe 仅在通过任务调度程序运行时抛出错误
【发布时间】:2014-06-01 15:29:08
【问题描述】:

我有一个在 Visual Studio 上开发的 exe。
当我们在服务器上运行它时,它将毫无问题地执行。
但是当我尝试通过任务调度程序执行它时,它没有运行。
请从事件查看器中找到以下错误消息。
请帮我解决问题

框架版本:v4.0.30319 说明:进程因未处理的异常而终止。 异常信息:System.IO.DirectoryNotFoundException 堆: 在 System.IO.__Error.WinIOError(Int32,System.String) 在 System.IO.Directory.InternalCreateDirectory(System.String,System.String,System.Object,布尔) 在 System.IO.DirectoryInfo.Create() 在 CentralMarketTransfer.HEB.CentralMarketTransfer.util.SimpleLogging.LogMessageToFile(System.String) 在 CentralMarketTransfer.HEB.CenteralMarketTransfer.main.ProjectMain.Main(System.String[])

【问题讨论】:

  • 我的超能力告诉我你在一个无权访问文件夹的帐户下运行任务。
  • 或者我的告诉我,这是一个具有不同基目录的相对路径。

标签: c#-2.0


【解决方案1】:

尝试显式设置任务的起始目录。您可以在任务计划程序中设置。

Select Task -> Right Click -> Properties -> Actions Tab -> Select Action -> Edit -> Start in (optional)

【讨论】:

    【解决方案2】:

    在我看来,直接执行exe和通过任务调度程序运行时,当前运行目录似乎不同。

    供参考:

    What is the default working directory for a scheduled task in Windows 2008 R2?

    Specifying the running directory for Scheduled Tasks using schtasks.exe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-11
      • 2018-04-26
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      • 2021-11-20
      相关资源
      最近更新 更多