Solved batch for close open file/folder by user on sharing drive

October 25, 2012 at 10:27:35
Specs: Win Server 2008
Hi All,

I have to update the database every week on share network drive.

Usually I used this batch to close open file on network drive call "closeopenfile.bat"

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

I run it from server side ( Win Server 2008 R2).

but my problem, it's close all open file on share drive, anyone can help me out how to modified bat file to close only file contains words (eg : AMC*.dat) or close only on sub folder share where the database that I want to update ( eg : E:\shareapps\RODS\database\weekly\ )

Really appreciated for find me out and many thanks!


See More: batch for close open file/folder by user on sharing drive

Report •


✔ Best Answer
March 14, 2013 at 23:49:47
Hi Jowah

Sorry for the late reply, as I promised here the command that I already used

net files | findstr /i "amc.*\.exe"
for /F %%a in ('net files ^|findstr /i "\\amc.*\.exe"') do net files %%a /close

net files | findstr /i "amc.*\.dat"
for /F %%a in ('net files ^|findstr /i "\\amc.*\.dat"') do net files %%a /close

net files | findstr /i "muparser.dll"
for /F %%a in ('net files ^|findstr /i "muparser.dll"') do net files %%a /close




#1
January 14, 2013 at 07:45:23
Hi genui,

I can help you with this if you still need it. We just need to add some list creation and cleanup, and then modify that for loop a bit. Let me know if you still want help.


Report •

#2
January 14, 2013 at 08:03:42
Hi Jowah
I would be very happy if you are willing to help me
I've got the answer from another forum, but maybe your answer and make it better able to help others in need.
sorry I have not been able to copy what I use now because the server is in the office.
I will show the batch that I used tomorrow.

Report •

#3
January 14, 2013 at 08:24:30
Genui,

Ok, I will wait for your script, and see if I can improve on it at all.


Report •

Related Solutions

#4
March 14, 2013 at 23:49:47
✔ Best Answer
Hi Jowah

Sorry for the late reply, as I promised here the command that I already used

net files | findstr /i "amc.*\.exe"
for /F %%a in ('net files ^|findstr /i "\\amc.*\.exe"') do net files %%a /close

net files | findstr /i "amc.*\.dat"
for /F %%a in ('net files ^|findstr /i "\\amc.*\.dat"') do net files %%a /close

net files | findstr /i "muparser.dll"
for /F %%a in ('net files ^|findstr /i "muparser.dll"') do net files %%a /close



Report •


Ask Question