Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » Microsoft help » [XP Pro] fsmgmt.msc - perform tasks in commandline
Search Topic:
Uniqs:
270
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
[XP Pro] Windows XP SP3 Available from Windows Update Site »
« [Service Pack 3] Windows XP Solution Center Updated  
AuthorAll Replies


ARIA
Linux
Premium
join:2002-04-15
Brooklyn, NY
clubs:

[XP Pro] fsmgmt.msc - perform tasks in commandline

hi guys i am new here but hope you can help me out.

I am trying to perform a task of breaking file locks hosted on an NFS file store. This has been a manual task for us. every time we need to deploy files.

we execute fsmgmt.msc map to a server, go to open files, select the files we need to close and close them.

What we are trying to do is to automate this process, I was wondering if this is possible to do in commandline.
--
the artist which was last known as ShavedBeaver


bcastner
Premium,MVM
join:2002-09-25
Chevy Chase, MD
clubs:
·Verizon Online DSL


edit:
May 6th, @02:02PM

1. You can execute this from a command line on the server:

for /f "skip=4 tokens=1" %g in ('net files') do net files %g /close

2. Using Microsoft/Sysinternals PsExec you could use a command line remotely; (or put the string in a "LockUndo.CMD" batch file and execute it remotely for each server):

===========

Rem LockUndo.CMD
Rem Example with two example servernames: test1 & test2
Rem Untested; there may be a syntax error. Concept piece only.

for %%h in (
"test1"
"test2"
) do (
psexec -accepteula -e "\\%%~h" "cmd /c for /f "skip=4 tokens=1" %%g in ('net files') do net files %%g /close"
)

exit

Or something similar to this concept. This closes all locks on all files on the servers in the list.

Resources:

Sysinternal's PsExec:
»technet.microsoft.com/en-us/sysi···553.aspx

--
============
MS-MVP 2004 - -2008, ASAP Member
Users Helping Users


dave
Premium,MVM
join:2000-05-04
not in ohio
·Verizon Online DSL

reply to ARIA
said by ARIA See Profile :

I am trying to perform a task of breaking file locks hosted on an NFS file store.
But the fsmgmt.msc plugin talks to CIFS servers (as does 'net files').


bcastner
Premium,MVM
join:2002-09-25
Chevy Chase, MD
clubs:
·Verizon Online DSL


edit:
May 6th, @03:13PM

I do not understand the problem you are raising with what I wrote.

net files /close will clear any of the four oploc types on files if the snap-in fsmgmt.msc will.

If you are thinking this is not really NFS but CIFS, you are likely right; but if the snap-in works, so will net file. (It could even be both).

dave
Premium,MVM
join:2000-05-04
not in ohio
·Verizon Online DSL

I was replying to the OP.

As far as I understand it, the snapin (and net file) will close the instance of the file that is open via CIFS, and not any other way.

So if remote cifs user has the file open as 'id 1' and a remote nfs user is accessing the same file(**) and a third local-to-server app has the same file open as well, then 'net file 1 /close' will close the cifs user's open file handle, but will do nothing for the remote nfs user's access and nothing for the local access.

All this is fine for cifs file servers (i.e. normal MS Windows Networking), but the OP specifically seems to be interested in nfs. So I'm confused as to what the real requirements are here. Just a typo and 'nfs' was not really intended?

(**)the nfs protocol doesn't really have the concept of open files, though of course the nfs server must open the file in the file system.

dave
Premium,MVM
join:2000-05-04
not in ohio
·Verizon Online DSL


edit:
May 6th, @03:52PM

reply to bcastner
Btw, psfile allows you to close a remote file; it's like 'net files' with a target system specification in the command syntax.

»technet.microsoft.com/en-us/sysi···552.aspx


ARIA
Linux
Premium
join:2002-04-15
Brooklyn, NY
clubs:

reply to ARIA
net files did not work but i figured out the command openfiles will work.

These are netapps filers

so the command "openfiles /disconnect /S servername /ID ####" works after I retreave a list of files by performing a query by "openfiles /query /S servername"

Thanks guys
--
the artist which was last known as ShavedBeaver


ARIA
Linux
Premium
join:2002-04-15
Brooklyn, NY
clubs:

reply to bcastner
said by bcastner See Profile :

1. You can execute this from a command line on the server:

for /f "skip=4 tokens=1" %g in ('net files') do net files %g /close

2. Using Microsoft/Sysinternals PsExec you could use a command line remotely; (or put the string in a "LockUndo.CMD" batch file and execute it remotely for each server):

===========

Rem LockUndo.CMD
Rem Example with two example servernames: test1 & test2
Rem Untested; there may be a syntax error. Concept piece only.

for %%h in (
"test1"
"test2"
) do (
psexec -accepteula -e "\\%%~h" "cmd /c for /f "skip=4 tokens=1" %%g in ('net files') do net files %%g /close"
)

exit

Or something similar to this concept. This closes all locks on all files on the servers in the list.

Resources:

Sysinternal's PsExec:
»technet.microsoft.com/en-us/sysi···553.aspx

Assuming that the servers are Win boxes. but interestingly I beleive they are NetApp OS


ARIA
Linux
Premium
join:2002-04-15
Brooklyn, NY
clubs:
reply to dave
thanks dave!

this will not work as the OS is netapps based and not a windows system. need a more lower level command interface.
--
the artist which was last known as ShavedBeaver


bcastner
Premium,MVM
join:2002-09-25
Chevy Chase, MD
clubs:
·Verizon Online DSL


edit:
May 6th, @04:19PM

reply to ARIA
You mean ONTAP?
That is NFS and CIFS.

Originally the filers were NFS and CIFS; then NFS only; then for non-block storage back to NFS and CIFS.

If you were using the fsmgmt.msc snap-in, you were using CIFS.

--
============
MS-MVP 2004 - -2008, ASAP Member
Users Helping Users


dave
Premium,MVM
join:2000-05-04
not in ohio
·Verizon Online DSL


edit:
May 6th, @04:24PM

reply to ARIA
said by ARIA See Profile :

thanks dave!

this will not work as the OS is netapps based and not a windows system. need a more lower level command interface.
It should work just fine. You run it on your Windows system, and it issues a CIFS RPC to the target CIFS server saying 'close this file'. Consequently it should work with any CIFS implementation that supports the necessary RPCs.


bcastner
Premium,MVM
join:2002-09-25
Chevy Chase, MD
clubs:
·Verizon Online DSL


edit:
May 6th, @05:09PM

reply to ARIA
You realize that there is a difference between an Open file and a Locked file?

Do you realize that the command: "openfiles /disconnect /S servername /ID ####" is a Windows/CIFS command?

Do you realize that the command "OpenFiles /Query /S RemoteSystemName" is a Windows/CIFS command?

You can modify my first FOR/DO/LOOP to avoid having to process the OpenFiles/Query command and parsing IDs:
(You need to modify RemoteSystemName to suite:

FOR /F "skip=3" %h IN ('OpenFiles /Query /S RemoteSystemName') DO (OpenFiles /Disconnect /S RemoteSystemName /ID %h)

===================================

Rem FileCloser.CMD
Rem Example with two example servernames: test1 & test2
Rem Untested; there may be a syntax error. Concept piece only.

for %%h in (
"test1"
"test2"
) do (
"psexec -accepteula -e "\\%%~h" "cmd /c for /f "skip=3 tokens=1" %%g in ('OpenFiles /Query /S %%~h') DO (OpenFiles /Disconnect /S %%~h /ID %%g)"
)

exit

===================================

You should also be able to use NET SESSION:

net session /Delete

/delete : Ends the computer's session with /ComputerName and closes all open files on the computer for the session. If you omit /ComputerName, all sessions on the local computer are canceled and all open files are closed.

--
============
MS-MVP 2004 - -2008, ASAP Member
Users Helping Users

Forums » Tech and Talk » OS and Software » Microsoft help[XP Pro] Windows XP SP3 Available from Windows Update Site »
« [Service Pack 3] Windows XP Solution Center Updated  


Friday, 09-Jan 07:05:35 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 9 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [162] New Comcast Throttling System 100% Online
· [112] After 10 Years Of Service, Charter Declares Home 'Unserviceable'
· [112] iTunes Dumps The DRM
· [73] AT&T, Verizon Stocks Tumble
· [64] Taxing ISPs to Prop Up Failing Newspapers?
· [62] DOCSIS 3.0 Gets Faster
· [56] Cable To Grab 75% Of New Subs In 2009
· [55] Feds Start Wait List For DTV Converter Coupons
· [54] Rumor: Google Cooking Up Own Router
· [48] Verizon Again Tweaks DSL Bundles
Most people now reading
· How to download windows 7 beta [Microsoft help]
· ERX06 latency [TekSavvy]
· What do you feel happens after someone dies? [General Questions]
· [Beta] Windows 7 Beta will be available Friday Jan, 9 2009 [Microsoft help]
· [ Professions] Northrend Herbalism and Mining Tracks [World of Warcraft]
· [Info] Microsoft Releases First "Fix it for me" KB Article [Microsoft help]
· Archivis' Guide to Naxx (10-man) [World of Warcraft]
· [WotLK] Hit Rating Cap - Hunters [World of Warcraft]
· Security Camera [Verizon Fiber Optics]
· FIOS TV Central website access with Non AT Router? [Verizon FIOS TV]