Re: Apple System Profiler
Re: Apple System Profiler
- Subject: Re: Apple System Profiler
- From: Sander Tekelenburg <email@hidden>
- Date: Sun, 11 Mar 2001 16:56:25 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 12:00 +0000 UTC, on 09/03/2001, email@hidden wrote:
>
I am being unbelievably thick - I can get individual snippets of
>
information about computers from Apple System Profiler but I don't seem to
>
be able to script it to make it produce a report.
No you're not thick. It's the dictionary writers who are thick. These kinds
of things really should be easier to find out.
>
If anyone has a sample
>
piece of code or can point me to some samples, I'd be very greatful.
I had a look and found the following things are important, and not obvious
from the dictionary:
1) ASP needs to be activated
2) "make new report" requires a location, but it is unclear what is meant
here by "location". After fiddling with it, I found that using the name of
one of the tabs in the report "System Profile", "Extensions", "Applications",
etc." is accepted (but not "Devices and Volumes"). Script Editor recognises
it. However, whioch ones you pick doesn't seem to make any difference. So I
don't know what this is about. I ended up just picking the first ("System
Profile") as it works.
It may be that the [with data anything] and [with properties record] options
mentioned in the dictionary have something to do with this, but I haven't
bothered to find out. If you do, please post your findings.
3) If you just say "save report", the report is saved into the Apple Menu
Items folder. In order to save it elsewhere, you must tell it to save to an
alias. But you cannot feed it a non-existing alias - it cannot coerce that.
So you need to first create an empty file somewhere, then tell ASP to save
the report to that empty file.
4) The information that ASP grabs seems to be dependant upon its preferences,
under "choose the info you want to appear iun a report". This doesn't seem to
be scriptable (which makes it particularly useless for distributed scripts).
Unless of course the "[with data anything] and [with properties record] "
options apply here...?
[Note that all this was under Mac OS 9.0.4 with ASP 2.4.4 (and Applescript
1.4.3). Things may be different under earlier/newer OS versions.]
So I ended up with a more or less working script that goes as follows:
+++++ begin script +++++
(* choose a name for the report *)
set theReportName to text returned of (display dialog "Choose a name for the
report" default answer "ASP Report")
(* choose where to save the report *)
set theContainer to choose folder with prompt "Choose the folder where you
want to store "" & theReportName & """
(* create empty file for ASP to write the report to *)
tell application "Finder"
set theLocation to (make file at theContainer with properties
{name:theReportName}) as alias
end tell
tell application "Apple System Profiler"
activate
set SysReport to make new report at system profile -- dunno why
save SysReport in theLocation
quit
end tell
(* Watch out for linewraps! *)
+++++ end script +++++
HTH
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <
http://www.pgp.com>
iQA/AwUBOqugFOsywKfXgqKdEQKhNQCgpwr/JfBgbfuP+p5r+Om29G7LD18AoO9f
A5UlJuCb/3ySBpjYEoSBcDeX
=CpeV
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <
mailto:email@hidden>
Web site at <
http://www.euronet.nl/~tekelenb/>
Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"