Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Automatically CLOSED an open shared file.

Posted on 2011-02-14
8
Medium Priority
?
1,352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

715 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