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?
CodePudding user response:
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.