6 Replies - 7765 Views - Last Post: 21 January 2010 - 03:14 PM Rate Topic: -----

#1 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 155
  • Joined: 25-December 09

Is It Possible To Close Open Files

Posted 20 January 2010 - 04:21 PM

Is it possible to use the windows function computer management->open files right-click close file, in vb to close out open files from an admin account. I have a program that use streamreaders and writers to read and write files, however it does it across a server and this causes files to get left open. I want to know cause right now the fix is manually going to the server workstation going to computer management and closing the file manually, is there a way to write a comand prompt program to do this for me on a timer?

Iv'e tried google i dont even know what to search on this one.

Is This A Good Question/Topic? 0
  • +

Replies To: Is It Possible To Close Open Files

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2253
  • View blog
  • Posts: 9,439
  • Joined: 29-May 08

Re: Is It Possible To Close Open Files

Posted 20 January 2010 - 07:49 PM

Do you remember to close the stream?
Was This Post Helpful? 0
  • +
  • -

#3 T3hC13h  Icon User is offline

  • D.I.C Regular

Reputation: 65
  • View blog
  • Posts: 337
  • Joined: 05-February 08

Re: Is It Possible To Close Open Files

Posted 20 January 2010 - 10:11 PM

run net help file from the CLI, wrapping this should provide a decent solution (besides closing the file locks). Also, Computer Management can connect to remote machines, that should save you abit of time RDPing to the server.

This post has been edited by T3hC13h: 20 January 2010 - 10:15 PM

Was This Post Helpful? 0
  • +
  • -

#4 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 155
  • Joined: 25-December 09

Re: Is It Possible To Close Open Files

Posted 21 January 2010 - 09:34 AM

I do remember close the file, the stream reader closes on exit so does the writer, and i want to run the file killing script on the machine the files are hosted on so its not remotely, and thats the current solution i have to walk to that machine and close them manually.
Was This Post Helpful? 0
  • +
  • -

#5 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 155
  • Joined: 25-December 09

Re: Is It Possible To Close Open Files

Posted 21 January 2010 - 11:54 AM

below is the vb,scripting version of what i want to do any idea?



Set objConnection = GetObject("WinNT://atl-ws-01/LanmanServer")
Set colSessions = objConnection.Sessions

For Each objSession in colSessions
	Wscript.Echo "Computer: " & objSession.Computer
	Wscript.Echo "Connected Time: " & objSession.ConnectTime
	Wscript.Echo "Idle Time: " & objSession.IdleTime
	Wscript.Echo "Name: " & objSession.Name
	Wscript.Echo "User: " & objSession.User
	Wscript.Echo
Next

Set colSessions = objConnection.Sessions


And here’s one that closes all the open files: How do i use this in vb.net and how do I set a set name of resources to kill cause i have specific files I want it to kill on a timer.


Set objConnection = GetObject("WinNT://atl-ws-01/LanmanServer")
Set colResources = objConnection.Resources

For Each objResource in colResources
	colResources.Remove(objResource.Name)
Next

This post has been edited by zukeru: 21 January 2010 - 11:55 AM

Was This Post Helpful? 0
  • +
  • -

#6 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 155
  • Joined: 25-December 09

Re: Is It Possible To Close Open Files

Posted 21 January 2010 - 02:38 PM

heres something that sortof does it but i dont understand how to kill the file http://www.codeproje.../OpenFiles.aspx
Was This Post Helpful? 0
  • +
  • -

#7 T3hC13h  Icon User is offline

  • D.I.C Regular

Reputation: 65
  • View blog
  • Posts: 337
  • Joined: 05-February 08

Re: Is It Possible To Close Open Files

Posted 21 January 2010 - 03:14 PM

nice find. The Open Files Client wraps the OpenFiles.exe CLI program.

Based on this technet article it looks pretty easy to use.

http://technet.micro...y/bb490961.aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1