Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3805704
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:43:12+00:00 2026-05-19T14:43:12+00:00

So I have an application ‘myApp’, and I have a preference to load ‘myApp’

  • 0

So I have an application ‘myApp’, and I have a preference to load ‘myApp’ at login.
I have this all running fine via launchd:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
      <string>com.myAppDomain.myApp</string>
    <key>ProgramArguments</key>
      <array>
        <string>/Applications/myApp.app/Contents/MacOS/myApp</string>
      </array>
    <key>RunAtLoad</key>
      <true/>
  </dict>
</plist>

I would also like to give the user the option of also hiding ‘myApp’

I tried creating a bash script, and adding to the ProgramArguments array in my lauchd plist:

#!/bin/sh

osascript=/usr/bin/osascript

$osascript -e 'tell application "System Events" to set visible of process "'myApp'" to false'

exit 0

but this either fails to run, or it more likely runs before my app has had a chance to initialise.

Is there an easier way to do this that I am simply overlooking?
thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:43:13+00:00Added an answer on May 19, 2026 at 2:43 pm

    You can just set a bool in your preference plist by calling

    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HideOnLaunch"];
    

    when the user chooses to hide your app on launch.

    Then, when your app is launched via launchd, your app itself can check the HideOnLaunch setting in applicationDidFinishLaunching:, and hide itself accordingly:

    if([[NSUserDefaults standardUserDefaults] boolForKey:@"HideOnLaunch"]){
         [[NSApplication sharedApplication] hide:nil];
    }
    

    Don’t let launchd to hide your app!

    Another approach would be the following: You can easily pass an argument to a Cocoa program. As described in this NSUserDefaults document, if you launch a Cocoa app like this:

    AnApp.app/Contents/MacOS/AnApp -FuBar YES
    

    Then you can get the value YES via [[NSUserDefaults standardUserDefaults] boolForKey:@"FuBar"].

    So, depending on the user’s preference, you can write a launchd plist setting an argument -HideOnLaunch YES or -HideOnLaunch NO.

    So, in your app delegate, presumably in applicationDidFinishLaunching:, hide your app depending on whether the program argument
    HideOnLaunch is set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application which consumes XML and based on this creates a GUI. Basically
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have application with this code: Module Startup <STAThread()> _ Public Sub Main() Try
I have application which is configured with svn and its working fine in my
i have application in which i have a web server api .this is my
I have application based on this tutorial Method I use to test connection to
I have application which loads images like this: someImage = Image.FromFile(@picture.png); and another application
I have application which can export slides to PowerPoint. I'm using Microsoft.Office.Interop.PowerPoint.dll . This
I have application built on asp.net MVC3. Application runs fine but I see one
i have application in which i have display question on allcard view and all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.