15

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] 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] 

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.

Hennes
  • 64,768
  • 7
  • 111
  • 168
Andrew Matthews
  • 335
  • 3
  • 10

2 Answers2

18

The solution is to supply /Y to force the delete. This isn't documented, unfortunately.

Nick Westgate
  • 1,811
  • 1
  • 16
  • 15
1

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

Hello71
  • 8,397
  • 5
  • 40
  • 44