如何通过已知 IP 断开 Windows 共享目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/688702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:13:10  来源:igfitidea点击:

how to disconnect a windows share dir by known IP?

windowsnetworking

提问by linjunhalida

windows only record 1 user/pwd to a remote share dir,

Windows 仅将 1 个用户/密码记录到远程共享目录,

and my program need to connect a dir,

我的程序需要连接一个目录,

but the user may login first, let my program failed to connect,

但是用户可能会先登录,让我的程序连接失败,

is there a method to disconnect it? i only know the IP.

有没有办法断开它?我只知道IP。

I use wnetcancelconnection2(remotedir) first, but still cannot work,

我首先使用 wnetcancelconnection2(remotedir),但仍然无法工作,

and return 1219 error(credentials supplied conflict with an existing set of credentials)

并返回 1219 错误(提供的凭据与现有的一组凭据冲突)

回答by sipwiz

net use \.0.0.1\sharename /user:domain\user 

to disconnect

断开连接

net use \\10.0.0.1\sharename /delete

回答by user83352

To disconnect one single computer/ip from a share. Use net session \IPADDRESS OR NAME /Delete or Net Session /delete to disconnect all client connections. You must run this command from the server which holds the share that is being connected to.

从共享中断开一台计算机/IP。使用 net session \IPADDRESS OR NAME /Delete 或 Net Session /delete 断开所有客户端连接。您必须从保存要连接的共享的服务器运行此命令。

Of course im not quite sure i read your question correctly.

当然,我不太确定我是否正确阅读了您的问题。

回答by wkf

Have you tried the NetUseDel function?

您是否尝试过 NetUseDel 功能?

NetUseDel Function

NetUseDel 函数

回答by See Takei

Your CMD window needs to be run with Admin rights. Found a more detailed explanation here:

您的 CMD 窗口需要以管理员权限运行。在这里找到了更详细的解释:

http://the-chronicon.blogspot.com/2015/01/disconnect-mapped-network-shares-via-cmd.html

http://the-chronicon.blogspot.com/2015/01/disconnect-mapped-network-shares-via-cmd.html