如何断开Windows远程目录的连接?

发布于 2024-07-16 14:36:08 字数 379 浏览 2 评论 0原文

我正在编写一个程序来监视远程目录, 我使用 Windows API:WNetAddConnection。 我用它通过使用指定的用户/密码将远程目录映射到 Z:。

当我把这个程序放到工作环境中后, 有人使用资源管理器位置“\192.168.XX\somedir”登录我监控的同一目录, 这使得我的程序无法连接到这个目录, 所以我必须要求这些人不要做这件事,但我不能强迫他们不这样做。

所以我想知道是否有办法断开所有其他连接, 或者证明他们做了这件事, 有人知道怎么做吗?

顺便说一句,我不是 Windows 专家, 我不知道 Windows 网络的细节(或者这个错误的真正含义), 谁能告诉我 Windows 网络的文档在哪里?

I'm coding a program to monitor a remote directory,
and I use the windows API: WNetAddConnection.
I use it to map remote directory to Z: by use a specified user/password.

After I put this program to the working environment,
someone use explorer location "\192.168.X.X\somedir" to login the same directory I monitored,
and it makes my program cannot connect to this directory,
so I have to ask this people not to do this thing, but I cannot force them not to.

So I want to know if there is a way to disconnect all the other connection,
or provent them do this thing,
do anyone knows how?

By the way, I'm not a expert in windows,
I don't know the detail of windows network (or what this bug really means),
can anyone tell me where is the documentation for windows network?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

红ご颜醉 2024-07-23 14:36:08

丑陋的选项:

您可以解析“net use”的输出,然后使用“net use /d”断开您不喜欢的连接

WNetCancelConnection2 似乎是 net use /d 使用的 API)

Ugly option:

You could parse the output of "net use" and then disconnect the connections you don't like using "net use /d"

(WNetCancelConnection2 seems to be the API that net use /d uses)

萌辣 2024-07-23 14:36:08
WNetCancelConnection2

但这并不是对人们最友好的事情。

WNetCancelConnection2

But it's not the friendliest thing to do to people.

流殇 2024-07-23 14:36:08

不确定 API,但 net session /delete 将断开所有打开的会话到共享的连接。

Not sure about the API but net session /delete will disconnect all open session to a share.

幽蝶幻影 2024-07-23 14:36:08

您可以按照以下步骤执行此操作:
1、运行命令删除所有网络用户和密码,命令为:
rundll32.exe shell32.dll,Control_RunDLL keymgr.dll
2、删除内存中所有网络用户信息使用命令:
网络使用* /删除/y
或者您可以创建一个包含以下信息的bat文件:

@echo off
rundll32.exe shell32.dll,Control_RunDLL keymgr.dll
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y

net use
net use
net use

net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y

you can do this follow the step:
1,run the order to delete all the net user and the passwd ,the order is :
rundll32.exe shell32.dll,Control_RunDLL keymgr.dll
2,delete all the information of the net user in the memory use the order:
net use * /delete /y
or you can create one bat file whit the follow information:

@echo off
rundll32.exe shell32.dll,Control_RunDLL keymgr.dll
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y

net use
net use
net use

net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
net use * /delete /y
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文