Solved

How to Automatically CLOSED an open shared file.

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

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Login Issue 4 55
Ms Filer Server Migration toolkit issues 2 66
AD user acount change history 4 67
OPINIONS please : best Active Directory Monitoring tool 5 135
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…
Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

806 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