Reputation: 147
How to open a file on desktop in lua program? Is there a simple way to do it?
I'm trying to make a addon for a game so when I'm in combat, It opens my mp3 file on my computer. It's running on Windows 10.
Upvotes: 1
Views: 1718
Reputation: 5021
To open a file in it's registered application you can use os.execute('start [file_path]')
, as stated by Henri and Bartek
the registered application is the application that launches when you double click the file icon, it is determined by the file's extension Examples: .lua
, mp3
, .txt
.
You can find/change the application in the properties window of the file on a windows system:
The start
param is not system independent, some systems will require open
rather then start
. Related information on determining os: how-can-i-determine-the-os-of-the-system-from-within-a-lua-script
Upvotes: 1