Re: Error message: NOT super-user?

  • Ok, I tried this:

    NSAppleScript *shutdown = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL URLWithString:@"shutdown.scpt" error:nil];
    [shutDown executeAndReturnError:nil];

    Here's shutdown.scpt:

    tell application "System Events" to shut down

    but it doesn't work. Am I doing something wrong?
    _________________________________________________________________
    News, entertainment and everything you care about at Live.com. Get it now!
    http://www.live.com/getstarted.aspx
  • On 8 Sep 2007, at 22:44, Ricardo Diaz wrote:

    >
    > Ok, I tried this:
    >
    > NSAppleScript *shutdown = [[NSAppleScript alloc]
    > initWithContentsOfURL:[NSURL URLWithString:@"shutdown.scpt"
    > error:nil];
    > [shutDown executeAndReturnError:nil];
    >
    > Here's shutdown.scpt:
    >
    > tell application "System Events" to shut down
    >
    > but it doesn't work. Am I doing something wrong?

    Yes, this:

    > [NSURL URLWithString:@"shutdown.scpt"

    You need to properly generate the path to the script. Ask NSBundle
    for the path to it and then create a URL.


  • Mike's technique will work, or you can avoid using a separate file at
    all and just pass the script as a string to NSAppleScript.

    On Sep 8, 2007, at 2:50 PM, Mike Abdullah wrote:

    >
    > On 8 Sep 2007, at 22:44, Ricardo Diaz wrote:
    >
    >>
    >> Ok, I tried this:
    >>
    >> NSAppleScript *shutdown = [[NSAppleScript alloc]
    >> initWithContentsOfURL:[NSURL URLWithString:@"shutdown.scpt"
    >> error:nil];
    >> [shutDown executeAndReturnError:nil];
    >>
    >> Here's shutdown.scpt:
    >>
    >> tell application "System Events" to shut down
    >>
    >> but it doesn't work. Am I doing something wrong?
    >
    > Yes, this:
    >
    >> [NSURL URLWithString:@"shutdown.scpt"
    >
    > You need to properly generate the path to the script. Ask NSBundle
    > for the path to it and then create a URL.
    >


previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today