Solved

How to Automatically CLOSED an open shared file.

Posted on 2011-02-14
8
1,202 Views
Last Modified: 2012-08-13
I was wondering if there a way to automatically close out an open shared file on a server running Windows 20303 Server? either some scripts, settings or any shareware or 3rd party tool to do this? Once a week, there's a need to do an update to the file and sometimes a user will have it open and forgot to close it out.  I know that I can do it manuall through the Computer / Properties Manager / goto the Shared folders portion and manually close it out before I do the updates.  I like to find a way to setup a task to do this automatically for me.  Any advised will me appreciated.
0
Comment
Question by:HaldunIT
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 34889717
http://technet.microsoft.com/en-us/library/cc732037.aspx

looks like you can setup a batch to call net file
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 34889756
0
 
LVL 2

Expert Comment

by:niaz
ID: 34889785
you can use the following commands and use them in a script to automate the process.

1. net file <ID> /close
2. net file myfile_id /close

for more detail, please see the TechNET link below

http://technet.microsoft.com/en-us/library/cc732037.aspx
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 34889808
The guy had a slight issue in his script:

This code will work.  Copy this and save as close_file.bat
launch like:  close_file C:\test.txt

The bat:

echo off
if "%1"=="" (echo You must specify a filename and path as the argument to this command) & goto :eof
if not "%2"=="" (echo Too many arguments) & goto :eof
net file > junk.tmp
for /f "skip=4 tokens=1,2 delims= " %%a in (junk.tmp) do call :parseit %%a %%b %1
del junk.tmp
goto :eof
:parseit
::%1 is %%a from above (the file id)
::%2 is%%b from above (the filename with path as output from the NET FILE command)
::%3 is the specified filename (as provided via commandline argument)
if /I "%2"=="%3" net file %1 /close & echo id %1 (%2) was closed
goto :eof
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:HaldunIT
ID: 34891852
Thanks Niaz and Ged325.
I got one question ged325.  On the batch file.
where is eof?
Do you need the EOF Lable since it's telling it GOTO?
Let me know and I will try it.
Thanks,
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 34892524
nope.  EOF means end of file which is apparently exit out.  Tried it on my own server at work to verify (had the same question).

0
 

Author Comment

by:HaldunIT
ID: 34897982
thanks ged325.  It works great.  Thanks for the help :)
0
 

Author Closing Comment

by:HaldunIT
ID: 34898005
Very fast response and helpful hints.  thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel file on a DFS share in use although it is not 3 43
Screen Mirroring 7 52
Group Policy & Netlogin Services 5 40
Active Directory delegation of control to a user 3 76
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now