Full path of file/files selected by mouse

Hi Guys,

Greetings of the day!

I have an interesting query. If I select a file in a directory by using mouse, Is it possible to fetch the path of this file using Powershell or otherwise? Is it stored somewhere in registry or file? I want to fetch full path of file for mouse event.


Thanks in Advance. Await your response.

Not sure this can be done with PS, at least not simply selecting a file. Might have a look at this:




Do you want this to fire any time a file is selected in explorer or do you want the script to launch an explorer window and retrieve a file? If it’s the latter then it can be done with windows forms. Here’s a simple example:

Add-Type -AssemblyName system.windows.forms
$fileselection = New-Object System.Windows.Forms.OpenFileDialog -Property @{
        InitialDirectory = "C:\Windows"
        Filter           = "*.*|*.*"
        Title            = "Select a File"
$null = $fileselection.ShowDialog()
"You selected {0}" -f $fileselection.FileName

If what you want is the former then you are in much more complicated territory and I would start with the link in TonyD’s post.