Discussion Locked

Closing a Resource

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Does anyone know how to close a resource from the command line? I need a command line way to mimic the action of going into Server Manager, choosing an open file, and clicking the Close Resource button.

6 replies

by mckaytech

If you know the file ID, you can use "net file [id] /close". I haven't figured out yet how you get a list of the open file IDs so I know this isn't the whole answer but maybe it will give you a starting point.

paul

by lbabson

Thanks. This did give me a start. I have to send the output of the net file command to a file. Use grep to search the file for the files I'm concerned about, extract the file ids, then use net file id /close. -A pain, but so far it's the only way.
Thanks again.

by _degan_

I'll be interested if someone has a direct answer to this question.

If you need to do this repeatedly, and the resource is an application, you can use the resource kit an make the application run as a service. Then you can easily use an NET START and STOP to control it.

by lbabson

Thanks for trying, but no, they are database files that remain open even if the application that uses them is closed. See my comment back to Paul if you're interested in the flips I have to go through to make this work.

by wayne.maples

The Windows NT Resource Kit includes Tlist.exe and PUList.exe which lists active tasks and processes and gives the pid . Combined with the kill command, you could do this.

-Wayne

by lbabson

Thanks for trying, but I need to close files, not processes. These are great tools though. See my comments to Paul to see how I finally got this to work.

This discussion is closed to new replies.