使用批处理文件静默取消共享文件夹

时间:2012-01-18 02:32:25

标签: silent

分享并重新分享文件夹。我得到了重新分享的部分,我被困在是不共享。

我使用此代码

NET SHARE d:\ foldername / delete

删除共享但是如果有人访问该文件夹,则提示继续,现在我希望此批处理文件无需任何提示即可静默运行。有什么想法吗 ?

3 个答案:

答案 0 :(得分:1)

我认为这更容易:)

NET SHARE d:\foldername /Y /delete

答案 1 :(得分:0)

将其放入文件yes.txt

Y [Newline]

现在

type yes.txt | NET SHARE d:\foldername /delete

答案 2 :(得分:0)

实际上没有必要提到完整路径.Windows将自己弄明白并删除。此外,没有意外删除两个具有相同名称@不同位置的文件夹,因为这是不允许的。您必须提供不同的共享名称。 所以这将工作得很好 “Shard”是我桌面上的文件夹

NET SHARE  foldername /Y /delete

请参阅下面的用例演示

    C:\Users\Administrator>net share \\w7\*  /y /delete
This shared resource does not exist.

More help is available by typing NET HELPMSG 2310.


C:\Users\Administrator>net share \\w7\users  /y /delete
This shared resource does not exist.

More help is available by typing NET HELPMSG 2310.


C:\Users\Administrator>net share c:\users  /y /delete
Users was deleted successfully.

c:\users was deleted successfully.


C:\Users\Administrator>net share c:\  /y /delete
C$ was deleted successfully.


c:\ was deleted successfully.


C:\Users\Administrator>net share c:\shard /y /delete
A matching share could not be found so nothing was deleted.

More help is available by typing NET HELPMSG 3719.


C:\Users\Administrator>net share shard /y /delete
shard was deleted successfully.