Automator: Correct syntax for calling an AppleScript file

I'm attempting to write an Automator application that will mount an external disk. I have an AppleScript that does the job and I'm attempting to insert it into an Automator application. However, rather than paste in the script I want to call the file, I have the following in Automator:

on run {input, parameters}
    run script file "Macintosh HD:Users/username/Documents/Scripts and Automator/mountdrive.scpt"
end run

However, this produces a syntax error:

Can’t make some data into the expected type.

Any suggestions as to the source of the problem?


Solution 1:

run script also accepts a "POSIX path", you don't need the explicit run handler:

run script "/Users/username/Scripts and Automator/mountdrive.scpt"

You could also add a Run Shell Script action where the content is osascript ~/Documents/Scripts\ and\ Automator/mountdrive.scpt.

Solution 2:

Try:

on run {input, parameters}
    set myScriptPath to (path to documents folder as text) & "Scripts and Automator:mountdrive.scpt"
    run script alias myScriptPath
end run