Using Python to open Explorer at specified path

I don’t know if this is possible via Dynamo. I’m wirting a file to a specific path and want to launch a Windows Explorer window at this path to make it easy for the user to grab the output.

This seems possible via Python (see this link for an example) but I keep getting the error “No module named subprocess”, which means it’s not importing some library/reference I suppose. Any ideas? Thanks!

You need to add the default IronPython library path first.

import sys
path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(path)

import subprocess
subprocess.Popen('explorer "C:\temp"')
5 Likes

Fantastic, thanks a lot Gui!

Thanks for this Gui.

Grasshopper users like myself are spoiled by the grasshopper python node, which allows users to import libraries without this. This little bit of code makes the dynamo python node work the same way as the grasshopper python node.