批处理关闭打开所有用户的文件

发布于 2025-02-05 02:53:34 字数 438 浏览 2 评论 0原文

FileServer 2019。 我想关闭除一个用户外的所有打开文件。

for /f "skip=4 tokens=1" %%a in ('net files') do net files %%a /close

现在,我尝试将其文件排除在内,我看到用户存储在第三代币中。

for /F "skip=4 tokens=3" %%a in ('net files^|findstr /i "Andrew"') do echo %%a

但是,如果我只搜索用户名令牌,我不知道如何关闭文件。如何返回文件ID? 因此,我尝试了Net会话:

net session \\<ip> /delete

但是我从同一IP地址连接了几个用户,因此我无法使用此用户。 有什么想法吗?

Fileserver 2019.
I want to close all opened files except for one user.

for /f "skip=4 tokens=1" %%a in ('net files') do net files %%a /close

Now, I tried to exclude a specific user with its files, I see that the user is stored in third token.

for /F "skip=4 tokens=3" %%a in ('net files^|findstr /i "Andrew"') do echo %%a

But I don't know how to close a file if I'm searching only username token. How to return back to file id?
So I tried with net session:

net session \\<ip> /delete

But I have several users connected from the same IP address, so I cannot use this.
Any idea?

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

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

发布评论

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

评论(1

勿忘初心 2025-02-12 02:53:35
for /F "skip=4 tokens=1,3" %%a in ('net files') do if /i "%%b" neq "Andrew" ECHO net files %%a /close

应向您显示要关闭的文件[理论],如果是的,请删除echo以激活的关键字。

我相信,来自Net Files的代表性示例将使这个问题更容易回答。并非每个人都使用多用户环境。

for /F "skip=4 tokens=1,3" %%a in ('net files') do if /i "%%b" neq "Andrew" ECHO net files %%a /close

Should show you the files to be closed [theory] if so, remove the ECHO keyword to activate.

A representative sample from net files would make this question easier to answer, I believe. Not everyone uses a multi-user environment.

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