我有一个由计划任务调用的应用程序.它从 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 指定计划任务的运行目录
发布评论