# “net share xyz /DELETE” fails if a file is in use on that share

I'm attempting, using NAnt, to disconnect a share (in order to redirect it somewhere else) but my attempt fails:

[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] External Program Failed: net (return code was -1)
[exec] The name has already been shared.
[exec]
[exec] More help is available by typing NET HELPMSG 2118.
[exec]


I can't see a way to supply the 'Yes' answer via the command line - there are not /Q switches. The target machine is a Windows 2003 server. Does DOS has an equivalent to the unix 'yes' command?

If I can do it on the command line, then I may be able to do it in NAnt's exec task.

-
sorry about the jumbled stream of consciousness. :S – Andrew Matthews May 19 '11 at 1:23
You use command.com too? – Hello71 May 19 '11 at 2:46
In actual fact this is part of a build and deployment tool. I'm using NAnt (a bit like make) to directly invoke the net command. – Andrew Matthews May 19 '11 at 7:14

Can't you just echo Y? If it's not using cmd, then just run it with %COMSPEC% /c echo Y | net....