How to open a graphics file on Windows using run()


On macOS I can do this:

run(`open $(filename)`)

where filename might be image.png or /tmp/test.pdf or /Users/me/test.svg, and the file will open in Preview or Safari or whatever app you’ve decided to make the default for that type of image.

What’s the equivalent on Windows?


You could try:

run(`explorer $filename`)

Maybe want to ignore the return status:

run(ignorestatus(`explorer $filename`))


Thanks, Greg, I’ll try this.


What do you try to display?


and please what is the version of this for Linux?


Perhaps xdg-open ?

run(`xdg-open $(filename)`)



Thanks, I’m on Windows and have only Winbuntu that has no graphical x11 tools but it suggested me to install it. So it probably works.

I dis ask this because I want to cover the 3 OSs and lacked the linux version.