# AuthorizationMBS pmset error

**URL:** <https://forum.xojo.com/t/authorizationmbs-pmset-error/85555>\
**Category:** Extras\
**Created:** [June 5, 2025, 1:36pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555 "2025-06-05T13:36:28Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [June 5, 2025, 1:36pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/1 "2025-06-05T13:36:28Z")

</div>

I try to wake up a sleeping Mac on a certain time.  
I does not, and when manually awaken it says access denied with error code -60005.  
What should I do differently?  
Here is the code:

var a as new AuthorizationMBS  
var d,t,s(2) as string  
var e as integer

s(0) = “schedule”  
s(1) = “wake”  
d = right(zeros+str(dt.Month),2)+“/”+right(zeros+str(dt.Day),2)+“/”+right(str(dt.Year),4)  
t = right(zeros+str(pHour),2)+“:”+right(zeros+str(pMinute),2)+“:”+right(zeros+str(pSecond),2)  
s(2) = gf+d+" "+t+gf

if a.SimpleNewAuthorization then ’ create

a.Execute(“/usr/bin/pmset”,s,true) ’ and run it

if a.LastError \<\> 0 then  
MsgBox "Lasterror on Execute: "+str(a.LastError)  
else  
e = a.Wait ’ wait for process to terminate. Returns PID  
if a.LastError \<\> 0 then  
MsgBox "Lasterror on Wait: "+str(a.LastError)  
end  
end  
msgbox a.ReadStream(1024)  
end

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [June 12, 2025, 6:16am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/2 "2025-06-12T06:16:05Z")

</div>

So I start with a basic snippet to run

```auto
dim s() as String
dim p,t as String
dim a as AuthorizationMBS
dim e as integer

p = "/usr/bin/whoami"

a=new AuthorizationMBS

if a.SimpleNewAuthorization then // create
  System.DebugLog "SimpleNewAuthorization "+a.LastError.ToString
  
  a.Execute(p,s,true) // and run it
  System.DebugLog "Execute "+a.LastError.ToString
  
  if a.LastError<>0 then
    MsgBox "Lasterror on Execute: "+str(a.LastError)
  else
    e=a.Wait // wait for process to terminate. Returns PID
    System.DebugLog "Wait "+a.LastError.ToString
    
  end if
  EditField3.text=a.ReadStream(1024)
end if

```

and I modify it to run pmset:

```auto
dim s() as String
dim p,t as String
dim a as AuthorizationMBS
dim e as integer

p = "/usr/bin/pmset"
s.Append "schedule"
s.Append "wake"
s.Append "06/12/2025 09:00:00"

a=new AuthorizationMBS

if a.SimpleNewAuthorization then // create
  System.DebugLog "SimpleNewAuthorization "+a.LastError.ToString
  
  a.Execute(p,s,true) // and run it
  System.DebugLog "Execute "+a.LastError.ToString
  
  if a.LastError<>0 then
    MsgBox "Lasterror on Execute: "+str(a.LastError)
  else
    e=a.Wait // wait for process to terminate. Returns PID
    System.DebugLog "Wait "+a.LastError.ToString
    
  end if
  EditField3.text=a.ReadStream(1024)
end if

```

Seems to work as “pmset -g sched” lists it on the Terminal now.

Maybe it’s just the gf you add for extra quotes, which prevents it from working?

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [June 12, 2025, 8:34am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/3 "2025-06-12T08:34:18Z")

</div>

I tried with gf = “” (hence no Gänsefüsschen) as in the example I read somewhere.  
Nevertheless, same problem occurs: it does not trigger, and when manually awaken it presents error code -60005… And a.readstream is empty.

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [June 12, 2025, 3:06pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/4 "2025-06-12T15:06:22Z")

</div>

If I try it in Terminal:  
sudo pmset schedule wake “06/12/25 17:01:00”  
it works.  
Under Xojo there is still this password? problem…

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 6, 2025, 9:55am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/5 "2025-12-06T09:55:55Z")

</div>

Christian, can you tell me what error code -60005 means in this plug-in?

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 6, 2025, 10:28am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/6 "2025-12-06T10:28:04Z")

</div>

Sorry, Christian, found out it is a MacOs problem. In Console I see this below. Any suggestion?

error 11:23:53.121488+0100 iAlarmClock parent received status=-60005

error 11:24:00.663640+0100 iAlarmClock AddInstanceForFactory: No factory registered for id \<CFUUID 0x600002614540\> F8BB1C28-BAE8-11D6-9C31-00039315CD46  
error 11:24:00.728372+0100 iAlarmClock MEMixerChannel.cpp:1636 client \<AudioQueueObject@0x7fd3f61a5800; [0]; play\> got error 2003332927 while sending format information

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [December 6, 2025, 10:29am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/7 "2025-12-06T10:29:24Z")

</div>

```auto
	errAuthorizationDenied = -60005, /* The authorization was denied. */

```

so just denied.

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 6, 2025, 11:05am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/8 "2025-12-06T11:05:20Z")

</div>

OK, thanks, I know. But why? Running from Terminal it works, from my App it doesn’t.

Do I need authoirze my app in Privacy somewhere??

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 6, 2025, 11:26am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/9 "2025-12-06T11:26:12Z")

</div>

Depending on what you’re attempting to do, I’m wondering if you may need entitlements in your Desktop app?

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 6, 2025, 8:19pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/10 "2025-12-06T20:19:19Z")

</div>

You mean something in App Wrapper, or just in the IDE?

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 12, 2025, 7:18am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/11 "2025-12-12T07:18:11Z")

</div>

Some progress…

The error -60005 appears because when trying to send the pmset schedule wake command during the sleepdemand of authorizationMBS, there is no time to answer this security dialog anymore, so I get this error present after (manual) wake-up.

So I placed a ‘fake’ wake and cancel command at the start of my app, so this issue is solved along as it runs (the mac runs).

But, the wake, although issued with a lasterror of 0, does not trigger the Mac to wake up at that time. Further, othis -60005 error still appears occasionally…

I’m at the moment clueless…

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 14, 2025, 5:04am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/12 "2025-12-14T05:04:10Z")

</div>

More info:

There is a .keeprights boolean I noticed that can be set so that one only has to interact with the macOS dialog once, so the '-60005 error is not returning.

When I execute the wake command, I get a lasterror of zero, but the authorized flag remains false…

Looking at the authorized 7 items, they are: uid, ap-token, username, ap-pam-service-name, pam\_result, gid, and ap-user-name. No idea if they are what it needs for issuing a pmset.

So the wake is still not triggered during sleep. Any suggestion?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 14, 2025, 5:07pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/13 "2025-12-14T17:07:34Z")

</div>

> [@Peter\_Kronenberg](#):
>
> You mean something in App Wrapper, or just in the IDE?

Well, I prefer to use AppWrapper for distribution, but for debug mode you’ll need to have the IDE do the settings correctly.

I’m not sure about wake from sleep. I don’t think that should need administrator permissions. I could be wrong on that.

However, I would _not_ be surprised if you do need some kind of entitlement and maybe even System Settings permission.

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 14, 2025, 9:56pm UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/14 "2025-12-14T21:56:50Z")

</div>

Thanks Tim, I’ll keep trying…

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [December 15, 2025, 10:57am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/15 "2025-12-15T10:57:09Z")

</div>

Well, first AuthorizationMBS is not the current way Apple likes to do it. Still works, but not preferred.

From AI:

> On modern macOS, the “current” way to do root‑level work from a GUI app is to install a privileged helper tool and talk to it over XPC, typically using SMAppService / SMJobBless and Authorization Services.​
> 
> ## Recommended approach
> 
> The usual pattern for a non–Mac App Store GUI app that needs to run things like `pmset` or call `IOPMSchedulePowerEvent` as root is:
> 
> - Use Authorization Services to get user consent once (the system shows an authentication dialog).​
> - Install a privileged helper tool using the Service Management APIs (historically `SMJobBless`, more recently wrapped via higher‑level APIs such as `SMAppService`). The helper is placed under `/Library/PrivilegedHelperTools` and launched as a daemon.​
> - Communicate with that helper via XPC from your GUI app. The helper runs as root and performs the limited, vetted operations you support (e.g., calling `IOPMSchedulePowerEvent`instead of shelling out to `pmset`).​
> 
> ## Important details
> 
> - The helper should be as small and locked‑down as possible, because it runs with full privileges; never expose generic “run arbitrary shell” functionality.​
> - This pattern is not allowed in the Mac App Store sandbox; store builds typically cannot schedule system wake or change system‑wide power settings because they cannot install such helpers.​
> - Using the underlying IOKit power management API (`IOPMSchedulePowerEvent`) directly in the helper is preferred over invoking `pmset`, which is only a user‑facing CLI wrapper.​

Instead of XPC you may just use a Socket in Xojo.  
I added the ServiceManagementModuleMBS years ago to do the JobBless part. Haven’t used it for a long time, but this used to work.

---

<div class="post-metadata">

**Author:** ![Peter\_Kronenberg](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_kronenberg/32/2891_2.png) [@Peter\_Kronenberg](https://forum.xojo.com/u/Peter_Kronenberg)\
**Post date:** [December 30, 2025, 2:12am UTC](https://forum.xojo.com/t/authorizationmbs-pmset-error/85555/16 "2025-12-30T02:12:30Z")

</div>

In Terminal you need to put a double quotation mark around date and time, as well for the cancel “wake”.

But with AuthoizationMBS, this is not needed, maybe it does it internally when passing the command via the CF plugin.

Unfortunately, there is now error warning for that, the pmset does just not happen (but a spin dump is generated).

Solution: no double quotation marks (Gänsfüsschen, above the variable ‘gf’), plus a test pmset command to trigger the macOS authorization prompt when launching the app, because later, when falling asleep, this prompt has no time to appear, and the error code -60005 will occur.
