Liu Chang asked a very similar question to this one here, Linux equivalent of the Mac OS X "open" command.
Is there a windows equivalent for the Mac OS X \"ope
Try explorer <filename>
. For example I wanted to launch a folder named abc
placed at desktop, so I used the command
explorer abc
I use to write
explorer.exe <file>
Just typing the file name into a console window will open the file in Windows. I tried several formats - .doc opened with OpenOffice, .mp3 opened with Windows Media Player, and .txt opened with Wordpad. This is the same behavior I experience when double clicking on the files.
If you use cygwin (or git bash), here's a quick script hack. Change the EDITOR to be whatever you want:
#!/bin/sh
# open
EDITOR="exec subl.exe"
BROWSER="/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"
if [ -d "$1" ]; then
exec explorer.exe $(cygpath -w "$1")
elif [ -f "$1" ]; then
path=$(cygpath --windows "$1")
case "$1" in
*.xml) $EDITOR "$1";;
*.txt) $EDITOR "$1";;
*.html) "$BROWSER" "$path";;
file://*) "$BROWSER" "$path";;
http://*) "$BROWSER" "$path";;
https://*) "$BROWSER" "$path";;
esac
else
# TODO non-existent file/dir
echo "non existent file: $1"
exit 1
fi
exit 0
I am answering this again as the accepted answer is not correct which is using the
start
command (which opens up the CMD as a new instance) and also because The Equivalent according to me isexplorer.exe
as also mentioned by others but not clarified as it should have been!
So, If you want to open the current folder like that with the 'open' command. you should use
explorer.exe .
which will open the current folder in explorer or if you just do the
explorer.exe
then you will open the default This PC location (whether it is recents or my computer or anything else)
It just works as in, when you just type in the file name it will just open in the default program just like
somevideo.mp4
and if you want that file/video to open/play with some other program just write down the program name with the full path (if it's not in the PATH system variable) followed by the filename like
"C:\program files\greentree applications\vlc.exe" somevideo.mp4
'start' is definitely the closest thing for Windows as @charles-duffy stated. Depending on your project there are also a few tools out there that solve this problem.
Node opn is a pretty great solution to be totally cross platform