Search This Blog

Sunday, November 06, 2011

Batch File: Force delete of share

I have recently found that there is a way to force delete a share. It was causing me grief in batch files as it was moaning there was an file in use and would want user input (Y/N).

You can actually use /Y in the command to force the yes, this is not list in the command help.

net share %Sharename% \\%COMPUTERNAME% /Y /DELETE

Someone else experienced this issue and has kindly forwarded this reference links, so I include them here. Thanks.

The MS docs that don't tell us:
http://technet.microsoft.com/en-us/library/bb490712.aspx
Expert's Exchange had the answer in 2008 but hides it at the bottom of the page:
http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_23154208.html
also just answered it on SuperUser:
http://superuser.com/questions/285543/net-share-xyz-delete-fails-if-a-file-is-in-use-on-that-share/


Share/Bookmark

4 comments: