title: Applescript: How to open a file with the default program?
body: <p>In an applescript, I receive one filepath that I've to open.</p>
  
  <p>The filepath is in the format "<code>/Users/xxx/my/file/to/open.xyz</code>".</p>
  
  <p>I want to open it with the default program. If it's an AVI, I need to open it with a video program, if it's an xls, with excel, ...</p>
  
  <p>I tried several things without any success:</p>
  
  <pre><code>--dstfile contains the previous path
  tell application "Finder"
      activate
      open document dstfile
  end tell
  </code></pre>
  
  <p>-->I'm getting the error 1728, telling me that he wasn't able to get the document </p>
  
  <pre><code>tell application "Finder"
      activate
      open document file dstfile
  end tell
  </code></pre>
  
  <p>--> Same here</p>
  
  <pre><code>tell application "Finder"
      activate
      open document POSIX file dstfile
  end tell
  </code></pre>
  
  <p>--> Same here</p>
  
  <p>I'm sure that the file exists because I do this before this code execution:</p>
  
  <pre><code>if not (exists dstfile) then
      display dialog "File isn't existing"
  end if
  </code></pre>
  
  <p>I cannot use the synthax open.xyz of to of... because I receive this as a parameter.</p>
  
  <p>Please help I'm desperate :'(</p>
  
  <p><strong>Answer</strong>: Based on answers, I end up with this:</p>
  
  <pre><code>set command to "open " &amp; quoted form of dsturl
  do shell script command
  </code></pre>