在Windows Scheduler中调度后如何获取已安装的exe文件系统路径? [英] How to get installed exe file system path after scheduling in windows scheduler?

查看:85
本文介绍了在Windows Scheduler中调度后如何获取已安装的exe文件系统路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在控制台应用程序中编写了一行System.IO.Path.GetFullPath("ApplicationSubDirectory")行,以获取应用程序目录文件系统路径.

I have written in my console application a line System.IO.Path.GetFullPath("ApplicationSubDirectory") to get application directory file system path.

我构建了此应用程序,并在系统中安装了exe. exe已安装在c://ProgramFiles/AppFolder/目录中.当我执行exe时,我得到了c://ProgramFiles/AppFolder/ApplicationSubDirectory之类的有效路径.

I build this application and installed exe in my system. exe has been installed in c://ProgramFiles/AppFolder/ directory. When I execute exe then I got valid path like c://ProgramFiles/AppFolder/ApplicationSubDirectory.

但是,当我安排此exe在Windows Scheduler中运行dailly基础时.然后我走错了路.这将向我返回安装Windows Scheduler的目录的路径,如c://Windows/System32/ApplicationSubDirectory.这是错误的路径.

But when i scheduled this exe to run dailly basis in windows scheduler. Then I am getting wrong path. This returns me path of directory where windows scheduler is installed like c://Windows/System32/ApplicationSubDirectory. This is wrong path.

请帮我安排调度exe后如何获得有效路径.

Please help me how i get valid path after scheduling exe too.

非常感谢.

推荐答案

这是因为您的控制台应用程序是由任务计划程序"启动的.要获取实际路径,请在您的应用程序中添加以下代码

This is because your console application is started by the Task Scheduler. To obtain the actual path add the following code to your application

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

这篇关于在Windows Scheduler中调度后如何获取已安装的exe文件系统路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆