Opening a file on desktop

Hi,
I’m trying to have a text document open off of my desktop. But the script has to work for different users on different machines.

this is what I got so far:

tell application “Finder”
activate
select window of desktop
select window of desktop
open document file “xxx.txt” of folder “Desktop” of folder “mac” of folder “Users” of startup disk
end tell

Please help

Jake

Hi Jake,

TextEdit opens txt files not the Finder.
the select window of desktop lines are complete unnecessary anyway

This opens the file xxx.txt on the desktop of the current user

tell application "TextEdit" to open ((path to desktop as Unicode text) & "xxx.txt")

doesn’t the path to desktop change depending on the machine and user?

path to desktop is always the desktop of the current user, regardless of the name of the user or name of the startup disk

Also, you can use “System Events” to open most common files with the default app, without having to hard codethe app into the script

tell application "System Events" to open ((path to desktop as Unicode text) & "xxx.txt")

Moved to OS X forum