NSUserName or NSFullUserName

Any tips on getting this? I realize it’s Foundation and I guess that means it’s not really accessible?
Tried without success:
set userName to current application’s NSFullUserName()
set userName to NSApps’s NSFullUserName()
set userName to NSFullUserName()

Would there be any benefit to using this:
making an Objective C class file that has a class function to return the NSFullUserName as a string? Have the ASOC call the Cocoa class method. That seems like a pretty long way around for 20 characters.
over this:
tell application “System Events” to set userName to (full name of current user). This works and is simple.

You’re right about not being able to access foundation functions through ASOC. There’s nothing wrong with using the tell application “System Events” method --why do you want to do it another way? It’s easy enough to do with an ObjectiveC class, if you don’t want to use the above method. Also you can get the current user, the same as NSUserName(), I think, using theNSProcessInfo class:

on applicationWillFinishLaunching_(aNotification)
		set info to current application's NSProcessInfo's processInfo()
		log info's environment()'s valueForKey_("USER")
	end applicationWillFinishLaunching_

But, as far as I know you can’t get the full user name (if that’s different) without calling SystemEvents or going the objectiveC route.

Ric

Why not


set userName to long user name of (system info)

Did you try them without the () ? They’re not really methods I think, they look like constants… could be wrong though, since they are CF. But I agree with Stefan and rdelmar, why not use the “system info” method? Especially for something so small, why write more than one line of code when you can do it in one?

But, it would have been fun to have access to these functions, there seems to be a lot of fun things in there. :slight_smile:

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)