我正在尝试使用 NAnt 断开共享(以便将其重定向到其他地方)但我的尝试失败:
[exec] Starting 'net (SHARE ad3-config /DELETE)' in 'c:\NAntDistributorBuilds\LocalInstallations\ad3config_master_1.0.19.4006'
[exec] Users have open files on ad3-config. Continuing the operation will force the files closed.
[exec] No valid response was provided.
[exec]
[exec] Do you want to continue this operation? (Y/N) [N]:
[exec] c:\NAntDistributorBuilds\LocalInstallations\ad3config_master_1.0.19.4006\install.build(32,6):
[exec] External Program Failed: net (return code was -1)
[exec] Starting 'net (SHARE ad3-config="c:\NAntDistributorBuilds\LocalInstallations\ad3config_master_1.0.19.4006" /UNLIMITED)' in 'c:\NAntDistributorBuilds\LocalInstallations\ad3config_master_1.0.19.4006'
[exec] The name has already been shared.
[exec]
[exec] More help is available by typing NET HELPMSG 2118.
[exec]
我看不出通过命令行提供“是”答案的方法 - 没有 /Q 开关。目标机器是 Windows 2003 服务器。DOS 是否有与 unix“yes”命令等效的命令?
如果我可以在命令行上执行此操作,那么我可能也可以在 NAnt 的 exec 任务中执行此操作。
答案1
解决方案是提供 /Y 来强制删除。这不是记录, 很遗憾。
答案2
你不能只用 吗echo Y
?如果它不使用 cmd,那么只需用 运行它%COMSPEC% /c echo Y | net...
。