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
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
setdesktop_topath todesktopasUnicode text write_to_file(the_profile, ((thepath & the_name) asstring), false)
– Include, but do not modify, the code below this line towrite_to_file(this_data, target_file, append_data) try setthetarget_filetothetarget_fileastext settheopen_target_fileto ¬ open for accessfiletarget_filewithwrite permission ifappend_dataisfalsethen ¬ set eofoftheopen_target_fileto 0 writethis_datatotheopen_target_filestarting ateof close accesstheopen_target_file returntrue onerror try close accessfiletarget_file endtry returnfalse endtry endwrite_to_file
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!!
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!