Solved

How to Automatically CLOSED an open shared file.

Posted on 2011-02-14
8
1,252 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RDM Dependencies on VMware 2 91
Moving SQl Server SBS 2003 to SQL Server 2014 27 138
how can I practice with windows server os 2 73
Glassfish admin console not working 1 36
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…
Learn about cloud computing and its benefits for small business owners.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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