How To Forcefully Close A File On Remote Computer Using Command Line?

by [Published on 24 Aug. 2008 / Last Updated on 27 Nov. 2008]

This article explains the steps you can use to close a file forcefully on a remote computer.

There are many ways to close an open file forcefully on a remote computer. For example, you can use Compmgmt.msc (Shared Folder snap-in) > Connect to the remote computer and then close the open files. There are two other methods you can use to close the open files which are explained in this article:You can use either Net File or PSFile (Microsoft utility) to close the files. The first command requires you to run the NET File command using the Psexec.exe remotely. The NET command doesn't support Remote APIs.
  • To close an open file on a remote computer using the Net File command:
Psexec.exe \\remote_computer_name NET FILE {ID_of_the file OR the file name} /close
  • To close an open file on a remote computer using the PSFile command:

PSFile.exe \\remote_computer_name {ID_of_the_file OR FIle_Path} -c

The -C directs PSFile to close the file. For more information on PSFile, visit the Microsoft Web site at:

http://www.microsoft.com/technet/sysinternals/Networking/PsFile.mspx

See Also


The Author — Nirmal Sharma

Nirmal Sharma avatar

Nirmal Sharma is a MCSEx3, MCITP and was awarded the Microsoft MVP award in Directory Services and Windows Networking. He specializes in Microsoft Azure, Office 365, Directory Services, Failover Clusters, Hyper-V, PowerShell Scripting and System Center products. Nirmal has been involved with Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to PowerShell-based Dynamic Packs for www.ITDynamicPacks.Net solutions.

Featured Links