2

这是一个简单的问题,当您使用启动任务时,您需要将 cmd 行放在 bin 文件夹中。

所以如果我不想把它们放在 bin 文件夹中如果我想把它放在解决方案文件夹中我应该怎么做。

4

1 回答 1

2

The execution path of the Start-Up Tasks is not configurable and properly set in some precompiled enviroment dlls. It is set to "approot\bin" for Web roles, and "approot" for Worker roles.

I don't know whether it is good practice or not and rather would not recommend it, but i also had done some research on it and found out, that you can define the Startup Task with relative folder path:

<Task commandLine="../init-bla.cmd" executionContext="elevated" taskType="background" />

This will run the init-bla.cmd from approot. But be aware: The context of the cmd stays in the bin folder.

For example, if you want to output something to a file or call another file, you have to be aware of the execution context. This example-code creates the output.txt file into bin folder, although it runs from approot.

@echo off
ECHO I_WAS_CALLED_ON_STARTUP >> output.txt

EXIT /B 0
于 2013-06-18T09:00:58.640 回答