I want to lock my Mac running OS X 10.8 after it has powered up with a script.
I have autologin enabled.
Open the AppleScript Editor, and type in this command:
Save it as a script file. Then, open your System Preferences, go to Account, and add it to the programs that will run upon login.
This command will not log you out; it does the same thing as using the fast user switcher.