How to identify If my executable is launched as User Agent in macOS

I have an executable in macOS that I m launching as a User Agent. The same executable can be launched in multiple ways like either user can directly click the exe to launch it, or user can launch it from the terminal using ./ etc. One similar way is when the user launches the exe as a User Agent(i.e daemon in user session).

In this scenarios, I want to identify in my exe If my user has launched it as agent to perform certain task.

I wanted to know how can I accurately determine this?

I have tried figuring out If there is some unique session that agents operate in, but I could not find anything. Can someone help here? Is this even possible?

The easiest way to do this is to add an argument to the ProgramArguments property in the agent’s launchd property list that tell the executable that it’s running as an agent.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to identify If my executable is launched as User Agent in macOS
 
 
Q