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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close/disconnect open files on servers

Status
Not open for further replies.

krinid

Programmer
Jun 10, 2003
356
0
0
CA

Question: is there a way to close/disconnect open files on server in VBscript?

I can see which files are open by parsing through as shown below, but is there a way to close the files using the information retrieved here?

Code:
Set obj = GetObject("WinNT://domain/server/LanmanServer")
for each objOpenFile in obj.Resources
    ...
next

I've seen one method which makes a call to the XP tool OPENFILES (openfiles /disconnect /s server /ID fileid), but is there really no way to do this natively within VBscript?
 
tsuji,
I tried to run your code on one of our servers here, but when it gets to the .Remove line, I get the following error:

Z:\Untitled1.vbs(23, 3) Active Directory: Not implemented

Or if I turn On Error Resume Next on and display the error:
Err 80004001: Not implemented

Any ideas what might be causing this?
 
Works for me, did you create a script like

Set objConnection = GetObject("WinNT://ServerName/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:

Set objConnection = GetObject("WinNT://ServerName/lanmanserver")
Set colResources = objConnection.Resources

For Each objResource in colResources
colResources.Remove(objResource.Name)
Next
 
I don't understand, but maybe it's just the way our network is set up?

Does anyone know what this "Not implemented" error is about?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top