使用 schtasks.exe 指定计划任务的运行目录 [英] Specifying the running directory for Scheduled Tasks using schtasks.exe

查看:106
本文介绍了使用 schtasks.exe 指定计划任务的运行目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由计划任务调用的应用程序.它从 Windows Server 2003 迁移到 Windows Server 2008.在 2003 年,该应用程序在可执行文件所在的目录中运行.2008 年 Environment.CurrentDirectory (C#) 报告说它在 C:\Windows\System32 中运行.如何设置运行目录?我正在使用 schtasks.exe 进行命令行部署.

I have an application which gets called by a scheduled task. It moved from Windows Server 2003 to Windows Server 2008. On 2003, the app ran in the directory where the executable was located. On 2008 Environment.CurrentDirectory (C#) reports that it's running in C:\Windows\System32. How do I set the running directory? I'm using schtasks.exe for command-line deployment.

UPD:通过界面,似乎是动作编辑屏幕上的开始于(可选)"字段.

UPD: Through the interface, it seems to be the "Start in (optional)" field on the action edit screen.

UPD:看起来使用 XML 文件可能会有所帮助,但我希望不用它.

UPD: Looks like using the XML file may help, but I'm looking to do without it.

推荐答案

我最近遇到了同样的问题.我解决它的方法是将/V1 开关添加到 schtasks 命令.

I recently came across the same issue. The way I resolved it was to add the /V1 switch to the schtasks command.

/V1 创建一个 pre-vista 兼容的计划任务并自动填充 Start In 目录.

/V1 creates a pre-vista compatible scheduled task and automatically populates the Start In directory.

这篇关于使用 schtasks.exe 指定计划任务的运行目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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