Close a file

If someone has a file open (either .txt, .mdb, etc...) in Win XP Pro over a network, it cannot be deleted because someone is tying it up.  How can I "terminate" this connection in order to be able to delete/rename the file?

This question is a  ** RUSH ** request.

Thank you,
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Dany BalianConnect With a Mentor CTOCommented:
'here's what u should do
'here's the vbs script

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "NET SESSION /DELETE /y" 'run batch file, Use your absolute path here

'i tried it, it works...
 hope this is what u want...


Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
There is no way that I know of to terimante a network connection with *any* file.

For Access apps, you can create custom programming to kick out users on a networked app.
I think MrDany solution will work... looks like it.
I would only question why involve Windows Scripting Shell.
The same command can be run directly from the built-in vb Shell command.
Dim plResult as Long

plResult = Shell("CMD.EXE /C NET SESSION /DELETE /Y", vbNoFocus)
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Dany BalianCTOCommented:
Hey jrcsystems,

thanks for pointing out to the shell command.

but the script that i gave was a vbs script cos i wasnt sure if Mike wanted a script for vb6 or vbs..

my solution works in both vb6 and vbs while the shell command is available only in vb6...



No problem. There is a place for scripting. I work almost exclusively in VB6 apps. Been in VBx for years.

I simply try to avoid scripting where possible because for Apps that are distributed outside the company,
(where you don't have control of sending out memos, telling collegues what to do)
too many anti-virus programs will raise a flag saying your App is trying to run a malicious script.
(even though it doesn't have a clue exactly what you are attempting).

CCIG2006Author Commented:
My wife has recently passed away and I am trying to take care of things.  I have not had time to review the answers, so I ask that you please allow more time.

Your cooperation is greatly appreciated.

Thank you,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.