Open files

Welcome Forums General PowerShell Q&A Open files

Viewing 2 reply threads
  • Author
    Posts
    • #165370
      Participant
      Topics: 23
      Replies: 15
      Points: 28
      Rank: Member

      What is the best and simplest way to detect the process currently opening a given file?

      Regards

      marius

    • #165379
      Participant
      Topics: 5
      Replies: 12
      Points: 93
      Rank: Member

      for a manual process, I use Process Explorer.  https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

      To do it automated with PowerShell, um um need someone smarter than me.

    • #165400
      Senior Moderator
      Topics: 8
      Replies: 1215
      Points: 4,335
      Helping Hand
      Rank: Community Hero

      You could use handle.exe

      with PowerShell, something like below.

      # Say I've opened a file named test.log
      Get-CimInstance -ClassName Win32_Process -Filter "CommandLine like '%test.log%'"
      
      # This filter is actually applied on CommandLine property of below output
      Get-CimInstance -ClassName Win32_Process | Select-Object -First 1 | Format-List *
      
Viewing 2 reply threads
  • The topic ‘Open files’ is closed to new replies.