I have the following powershell script that brings me the path of the open folders in windows
$app = New-Object -COM 'Shell.Application'
$app.Windows() | Select-Object LocationURL
And I want to do the same thing in python, but the Select-Object LocationURL
part I can't do it
from win32com import client
shell = client.Dispatch("Shell.Application")
shell.Windows()
How to replicate $app.Windows() | Select-Object LocationURL
in python?
CodePudding user response:
You can iterate shell.Windows()
and use the LocationURL
attribute, like so:
from win32com import client
shell = client.Dispatch("Shell.Application")
for window in shell.Windows():
print(window.LocationURL)
Output:
file:///C:/Users/Admin/Downloads
file:///C:/Stuff