Solved

How to Automatically CLOSED an open shared file.

Posted on 2011-02-14
8
1,188 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 39

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 39

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 39

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 39

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

21 Experts available now in Live!

Get 1:1 Help Now