如果该共享上正在使用文件,则“net share xyz /DELETE”失败

And*_*ews 15 network-shares command-line windows-server-2003

我正在尝试使用 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] 
Run Code Online (Sandbox Code Playgroud)

我看不到通过命令行提供“是”答案的方法 - 没有 /Q 开关。目标机器是 Windows 2003 服务器。DOS 是否具有与 unix 'yes' 命令等效的命令?

如果我可以在命令行上完成,那么我也许可以在 NAnt 的 exec 任务中完成。

Nic*_*ate 18

解决方案是提供 /Y 来强制删除。不幸的是,这没有记录


Hel*_*o71 1

你就不能吗echo Y?如果不使用 cmd,则只需使用%COMSPEC% /c echo Y | net....