Applescript "mixed credentials" error - applescript

I asked this question over on the Apple Communities and got a grand total of ZERO responses. You guys seem a whole lot smarter, so thought I would ask here to see what you think.
An error has started occuring when I attempt to trigger an Applescript via an external process. The console error is as follows:
12/09/2012 11:01:39.205 osascript[269]: Scripting addition loading restricted to system domains because this process has mixed credentials (issetugid=0 r/e uid=501/0 gid=20/20)
When I run the script locally on the Mac(Mini - Mountain Lion 10.8.1) it works perfectly.
What is happening is as follows.
I have a MacMini as a music server in a home automation environment powered by a Crestron processor. The MacMini is connected to two zones, one via the Optical output and another to a DAC from one of the USB ports. When I selected "Listen to iTunes" in one of the two zones the controller sends a command via UDP to a program running on the MacMini which triggers the scripts to change to the appropriate audio out.
All was working well until yesterday when all of a sudden the program triggering the script, whilst reporting that it has executed the correct script correctly, isn't switching the output and the above message is appearing on the console.
I have read what I can on here and as such have reset the PRAM and SMC (all three dongs...) and deleted the script triggering program, run Clean My Mac and rebooted, all to no avail.
Can anyone help me with this, it has to be something simple given that it was working...surely? I haven't run an update or changed anything else that I can think of.....
Any and all thoughts and input would be greatly appreciated.
Thanks
Marc

From the error it seems that you have an add-on to applescript called a "Scripting addition" installed, and that's causing the error. Most likely you do not need this add-on to perform your applescript code. So I would remove all scripting additions from my system and see if the applescript still works.
Search your system for scripting additions... ~/Library/ScriptingAdditions and /Library/ScriptingAdditions.
If you do need to do something that the scripting addition is doing for you, then there's probably other ways to perform the same task without the add-on.

Related

How to stdout/stderr for MS Office Applications?

Hey I'm working on Windows in an office environment with an uncooperative MS Access database.
We're experiencing crashes and hangs with no error messages. I am used to a *nix environment where I can launch a program from the terminal and get stdout/stderr redouts making it much easier to see what was running just before it crashed the computer...
Experimenting with launching from windows' cmd hasn't yielded anything similar (not dug too far into powershell because I'm not allowed admin privileges on this machine ¬_¬). Does anyone know a way I can dig beyond a hanging GUI and get at a readout of logs, or preferably see messages piped to the command-line as the program whurrs away?
Worth noting I'm in a restrictive IT environment where I cannot install any additional tools, so whilst I'll be interested to hear about the wonder program that will solve my problems I'll be unable to install anything that isn't built in to Windows.
There is no such thing in MS Access.
You will have to write your own error handling that will write errors to a log table or log file. Of course, this will only work until your application halts.
The behaviour you describe is not normal, so the cause for your trouble may very well be anything but MS Access itself.

Using VMMap in a batch script

I am doing some analysis work on some software we are running where I work. The software seems to have memory issues some where along the line which are proving difficult to track down. We have decided to use Sysinternals VMMap to track the memory being used by the software.
We have VMMap exporting the usage every 20 seconds using Windows scheduler to launch a batch script which pulls back the target process PID and launches VMMap with it. The process runs for a while, output appearing the out directory but after a while it stops. Windows scheduler reports the job ran fine and will start another instance when the trigger is meant, once again with no output.
After a bit of investigation it looks like VMMap is failing to open the process and is trying to report an error through its GUI. Since we are running in batch, we cannot see this error to dismiss it. This is causing numerous process' to be spawned but not actually doing anything.
Has anyone come across this issue when using VMMap, or know of anything that may help? I am thinking there may be some flag I can pass which suppresses messages or maybe some way I can handle it in the batch but Google hasn't helped nor has the Sysinternals forum. Any help would be really appreciated.
VMMap is a GUI tool, so trying to capture its output in an automated way will be difficult. Instead, try using another SysInternals tool, Handle, that captures a lot of the same information, but exports/reports on it in command line, where it can be captured much easier. Alternatively, don't run the output in an auto-repeating way when using VMMap, but instead have your script somehow detect the error or missing expected results/data and stop so the GUI output can be examined.
All Sysinternals tools do pop up a consent dialog for the first time they are started on a new machine to accept their license. I think you did deploy the tool to a production machine and it was trying to show the consent dialog but nobody did press ok.
They do basically create a registry key on the machine which you can fake if you need a fully automated deployement or you can start in once on the target machine for the user in question.

AppleScript (or other code?) to change iTunes library depending on disk presence

I have my large music library on my external drive, and a more portable sized library on my internal drive. What I really would like to have is an app that checks for the presence of my external drive and then proceeds to launch iTunes with the correct library.
I am aware of the question here, and while that may be pretty close to what I want to do, I do not know enough Applescript to make it happen. There is also this neat script , but it gives me this error: "Finder got an error: ln: /Users/Matt/Music/: Permission denied" and I don't know how to change permissions for that to work. Plus I don't need it to function for every user, although it isn't a big deal.
There is another guy who got his situation resolved with ControPlane, which I currently use for other purposes. I could not figure out a sensible way to run the script only when I launch iTunes and still have it switch my Network prefs for when I'm at work or home.
Would changing one of those Applescripts work best? If so, how can I make it work? Or could we have ControlPlane run a script changing which library iTunes will open, depending on if my drive is connected or not? (While still maintaining my correct network settings)...
Any advice would be greatly appreciated. Thanks guys!
Another solution you might try is using Keyboard Maestro. You would be able to build a trigger for iTunes, so that launching the application would run a script, and that script could choose the appropriate library based on the presence of the external drive.

Identify a reboot

Is there any "Boot session ID" or (reliable) "Boot timestamp"?
For an installation I need to detect that a scheduled reboot took place indeed.
I guess I could do a dummy MoveFileEx() with MOVEFILE_DELAY_UNTIL_REBOOT, but i did hope for something easier.
(We have to install a 3rd party package that sometimes behaves erratically after an repair/update. In that state, accessing the device may even lock up the system)
(Windows XP, Vista, 7)
For things like this, WMI (Windows Management Instrumentation) is often a good starting place. I know you can get current uptime directly through it, which may allow you to determine if a machine recently rebooted.
Here is a blog post with some code samples as well:
http://blogs.technet.com/heyscriptingguy/archive/2004/09/07/how-can-i-tell-if-a-server-has-rebooted.aspx
Depending on your implementation language, you probably just want to pull out the query code from the vbscript.
Apparently Windows has the equivalent of "uptime". Here's more info: http://support.microsoft.com/kb/555737
As I understand it, this should tell you how long ago the system was booted. Will that information solve your problem?
You could search the System event log for event 6009 from the EventLog source - this is the first event recorded after each reboot.
I think the best answer has already been given here: Find out if computer rebooted since the last time my program ran?
That seems to be the simplest way. Use GlobalFindAtom() to see if it exists and create it, with GlobalAddAtom(), if it doesn't. It will persist beyond the execution of your program. If your application runs again, and sees that the atom exists, then then it isn't the first run since reboot.
If the computer is restarted, then the atom won't exist, indicating that this is the first run of your program since the reboot.

Stop VB application from running in background

I have a console application (written in VB6 ) which is behaving strangely on my machine. I kick it off from the command line and what should be a two minute job drops straight back to the prompt - if I run this on another machine the executable will sit and wait until the job finishes before returning control back to the prompt. If I check process explorer I can see that the executable is running as a background process and other than this strange background-ness is running as expected.
Any thoughts on why this could be happening? (Running on 32-bit Windows XP Pro SP3.)
It's totally unclear whether this is an application you wrote and have the source code for. If that's the case, you need to get in and start debugging. At the least, use OutputDebugString to send information about what's going on to any number of potential viewers. Taking that a step further, consider rewiring the app using the Console module I wrote, along with vbAdvance to recompile. This combination will allow you the full power of the VB6 IDE to debug within. No more guessing about what's going on.
Then again, if it's not your app, I'm not sure what VB6 has to do with it and wish you the best of luck trying to figure out what's up.
It sounds to me as though the app isn't being recognised as a console app on one of your machines. Console apps weren't officially supported in VB6, although there are some well-known hacks for creating them (particularly the free add-in vbAdvance). Possibly your console app is a bit unreliable? If Windows thinks your app is a GUI rather than a console app, it won't wait for it to finish.
As a pragmatic workaround: try launching with start /wait rather than just using the exename. That forces the command prompt to wait for the program to finish, whether it's a GUI app or a console app.
Sounds like an error is occurring that is being 'swallowed' by the application. Do you have the source code?
Errors in VB6 apps are often due to some COM component not installed and/or registered.
Download SysInternals Process Monitor and this will show up accesses to ProgIDs that fail (uninstalled/unregistered COM components).
Check out: Process Monitor - Hands-On Labs and Examples.
Have you checked permissions? Is the application accessing any network based resources?

Resources