Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to close open files.

Status
Not open for further replies.

pmaths

MIS
Feb 15, 2007
37
GB
Hi - We are running windows 2000 server. I want to be able to give one of our users the ability to close certain open files on our data (windows 2000) server. And really wondered what the best way to do this would be. I was thinking via a script maybe but I'm unsure of the contents that the script would require to do this.

At the moment I close the open files for the user through computer management - shared folders - open files, but obviously I'm not always here to do this.

Any help on this would be gratefully received.

Cheers
 
There is a command line to do it, just can't remember it

'closes all the open sessions on a computer:

Code:
Set objConnection = GetObject("WinNT://serverName or ComputerName/LanmanServer")
Set colSessions = objConnection.Sessions

For Each objSession in colSessions
    colSessions.Remove(objSession.Name)
Next
'And here’s one that closes all the open files:

Code:
Set objConnection = GetObject("WinNT://serverName or ComputerName/LanmanServer")
Set colResources = objConnection.Resources

For Each objResource in colResources
    colResources.Remove(objResource.Name)
Next
 
net session \\<systemname> /DELETE

-Brandon Wilson
MCSE00/03, MCSA:Messaging00, MCSA03, A+
Sr. Infrastructure Management Analyst
Distributed Systems Engineering
ACS, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top