OPENFILES.exe – Windows CMD Command

Query or display open files, disconnect files opened by network users.

Administrator privileges are required to run the OPENFILES command. We can use this fact to detect if the current user is an Admin ( OPEN FILES >nul 2>nul will set %ERRORLEVEL% = 1 if the user is not an administrator.) However this will fail when running under WOWf4t e.g. running a 32-bit installer on a 64-bit system, so an alternative is to use NET SESSION.

Running openfiles.exe from within powershell allows the output to be easily assigned to a variable.

You may also like...

2 Responses

  1. zoritoler imol says:

    Enjoyed studying this, very good stuff, appreciate it. “The fox knows many things, but the hedgehog knows one big thing.” by Archilocus.

  2. zortilo nrel says:

    I genuinely treasure your work, Great post.

Leave a Reply

Your email address will not be published.