Scripting the System Profiler???

I am trying to automate the series of events that it would take to launch and save the Sytem Profile information in Rich text format. It seems to execute up the last step and the error “System Events got an error: NSReceiverEvaluationScriptError: 4” occurs at the click menu item “Rich Text…”. Any suggestions would be much appreciated.

tell application “System Profiler”
activate
tell application “System Events”
tell process “System Profiler”
tell menu bar 1
tell menu bar item “File”
tell menu “File”
tell menu item “Export”
tell menu “Export”
click menu item “Rich Text…”
–delay 1
----This retrieves short date
–set dateString to do shell script “date ‘+%y%m%d’”
----This retrieves serial number
–set serial_number to do shell script “system_profiler -detailLevel -2 | awk ‘/Serial/{print $3}’”
----This concatinates documents name, date, and serial number
–keystroke “System_Profile” & “" & dateString & "” & serial_number
–click button “Save”
end tell
end tell
end tell
end tell
end tell
end tell
end tell
–quit
end tell

THANKS!!!

a more effective approach may be to use the application dictionary instead of UI scripting

Just drag the application icon on top of script editor to see the dictionary

The dictionary method is too Greek to me to understand. Is it like an object browser? How do interpret the information?

set thepath to path to desktop
set the_name to do shell script “date ‘+%y%m%d’; system_profiler -detailLevel -2 | awk ‘/Serial/{print $3}’”
tell application “System Profiler” to set the_profile to get system profile

you could then use this info for whatever you needed
pass it into another app or whatever

like this

you could save it as a text file using apple’s essential sub-routine http://www.apple.com/applescript/guidebook/sbrt/index.html

set thepath to path to desktop
set the_name to do shell script “date ‘+%y%m%d’; system_profiler -detailLevel -2 | awk ‘/Serial/{print $3}’”
tell application “System Profiler” to set the_profile to get system profile

set desktop_ to path to desktop as Unicode text
write_to_file(the_profile, ((thepath & the_name) as string), false)

Include, but do not modify, the code below this line
to write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file

this script was automatically tagged for
color coded syntax by Script to Markup Code
written by Jonathan Nathan

notice also that you can run more that one shell script at once by seperating them with a “;”

How would you specify retrieving applications residing on the specifice machine? Is there a sub routine to the “get system profile” for retrieving applications? Thanks for the help!!

Not sure i understand what you are asking

if you need to call an application on the local machine you just call it by name

tell app “finder” …

or tell app “Adobe Photoshop”…
or tell me → the script running

i hope that answers your question

Ultimately what I am trying to do is use the System Profiler to get Application’s installed on a machine. The only way I know how is through the System Profiler. Which allows you to put it into a Rich Text document, that I can later parse out into meaningful reports i.e. App names, versions and so on. If there is an easier way of doing this I am all ears. Thanks!