Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A shell/AppleScript interaction trick' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A shell/AppleScript interaction trick
Authored by: gmagerr on Jun 19, '04 07:58:07AM

Hey guy's I modified a script that was posted a few weeks ago. I want to find a way to have my users machine serial number automatically entered into one of the 4 computer info fields of the sharing window. This is the best thing I've come up with. The only thing i don't like about it is that the system preferences window is visable during the whole action. I'd like to figure out how to hide that. Anyway i thought this was a cool way to use this hint. This can be used as a login script I suppose. that is if you have ARD.

[code]
exec osascript <<EOF
set Profile to do shell script "/usr/sbin/system_profiler SPHardwareDataType"
set SN_Start to ((offset of "Serial Number" in Profile) + 15)
set Partial to text SN_Start thru (length of Profile) of Profile
set SN_End to offset of " " in Partial
set SN to text 1 thru SN_End of Partial
tell application "System Preferences" to activate
tell application "System Events"
get properties
tell application process "System Preferences"
click button "Sharing" of scroll area 1 of window "System Preferences"

delay 3
keystroke tab
keystroke tab
delay 3
tell application "System Events"
repeat 5 times
keystroke (ASCII character 31)
end repeat
end tell
delay 3
click button "Access Privileges…" of tab group 1 of window "Sharing"
delay 3
set value of text field 1 of group 1 of sheet 1 of window "Sharing" to SN
click button "OK" of sheet 1 of window "Sharing"
keystroke tab -- forward tab key
tell application "System Preferences" to quit

end tell
end tell
[/code]



[ Reply to This | # ]
A shell/AppleScript interaction trick
Authored by: RickoKid on Jun 20, '04 05:37:56PM
Try using this to hide System Preferences:

tell application "System Preferences" to activate
tell application "System Events" to tell process "System Preferences" to keystroke "h" using command down


[ Reply to This | # ]