1

I've been researching and learning about windows batch files, PowerShell and cmd these past few days.

We're having issues with Open Files, so we manually go to the server and do it with a press of a button. But since there might be a possible way to automate it and do the script every 5 minutes.

Someone helped me already telling me that I should make a script of

openfiles /disconnect /a* /op "E:\SERVERNAME\"

& so I did and put it on the Windows Task Scheduler Action Tab - Start a Program and put the file path of the batch file that I made.

But It seems that it's not working and we're still having the same issue.

I hope I made it clear.

Drew
  • 3,814
  • 2
  • 9
  • 28
CK9
  • 11
  • 2
  • 2
    You do realize that this is likely to cause data loss due to unsaved changes, don't you? – Ansgar Wiechers Nov 20 '18 at 00:49
  • So what's the best way to do if the file is locked but we already saved and closed it? so the other won't be affected by it especially the ones that some people are still handling. – CK9 Nov 20 '18 at 01:09
  • 2
    If it's saved and closed, why would it be open? – SomethingDark Nov 20 '18 at 03:21
  • The best way is to find the source of the locking. Most likely the application that is creating a FileStream (aka writing to the file) isn't properly disposing of it's resources. If this is a .NET application that would mean there is a missing using statement. – P.Brian.Mackey Nov 20 '18 at 03:55
  • If it's powershell that's writing to the file then calling `Dispose()` should do it. Also see https://stackoverflow.com/questions/14294055/file-io-is-this-a-bug-in-powershell – P.Brian.Mackey Nov 20 '18 at 03:58

0 Answers0