Nant在不同的用户下运行exec任务



是否可以使用不同的域和用户运行Exec任务?

我需要在10个负载均衡器上重新启动iis,这可以用Nant-exe任务实现吗?

现在我有这样的脚本

<exec programm='iisreset'>
  <arg line='${balancer}'/>
  <arg line='/restart' />
 </exec>

这是在集成环境中工作的(因为是同一个域),在测试中失败,Acces Denied。。

感谢

您可以在exec调用中使用命令runas,并使用/netonly参数远程访问平衡器。

我想这可能看起来像这样:

<exec program="runas">
  <arg line="/netonly" />
  <arg line="${'/user:' + domain + '' + username}" />
  <arg line="${'&quot;iisreset ' + balancer + ' /restart&quot;'}" />
</exec>

这可能对你有用,但我不确定你将如何自动给他密码。不过,您可以在cmd中使用/savecred运行runas一次。但要小心保存密码。。。

请注意,我无法对此进行测试,因为我没有进行测试所需的环境。

来源:http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true

最新更新