MacOS creating launch agent in a console app not working - macos

I know how to create a launch agent with a normal application say "myLaunchd" and setting "Application is agent" to "YES" and then copying the "myLaunchd.app" to the main app's Contens/Library/LoginItems.
But I need agents, which will be created by some scripts and the main-app's bundle-identifier will be provided through command line arguments.
I tried with a console app, tried using it as launch agent, but it doesn't work expected. I noticed that a normal app keeps running until it is closed (if "Application is agent" is set to "NO"). So to achieve similar effect I forced the console app to run-infinitely using while(1), but no luck.
Any suggestion will be appreciated.

Related

Is there a way to trick GUI applications in docker to think their window loaded?

I try to run an windows 10 application inside a windows servercore container.
The app can run without user input via COM-Interface (and without visible GUI), but it seems that it needs to load a hidden window in the background. When I start it on docker, the application log file indicates that it's stuck on starting this window.
Is there a way to make the app assume it successfully loaded the window?
All information I found so far was about users who want to see the GUI or about Linux/Windows combinations. None of that helped me.

Can't Change Input Method when Launching App with Admin Privileges

I wrote a script using the Mac script editor on Mojave (10.14.15)
The script simply launches an application with Admin privileges:
on run
do shell script ¬
"/Applications/App.app/Contents/MacOS/App" user name "name" password "pw" with administrator privileges
quit
end run
I then saved this as an application and am able to launch successfully using it.
However the application that I launch (Anki study software) can not change the input setting, which means I am unable to type in any language except the default system language.
Note that making a similar application in script editor that launches without admin privileges works without issue,
ie:
on run
do shell script ¬
"/Applications/App.app/Contents/MacOS/App"
quit
end run
This seems to be the case no matter the app I launch, I also tried launching Sublime Text and the same thing occurs.
The issue also happens when using sudo to launch an app from terminal. So it definitely seems to be an issue with trying to launch an app as root.
I am new to working with AppleScript and MacOS. It seems the fault is with launching the application with admin privileges though. Any help would be greatly appreciated.

OSX running app acts differently from running on terminal

I have written an app for OSX (Sierra) in Go (lang) with the GUI powered by the Golang QT binding therecipe/qt. When I build the app and run it from the command prompt with command open $(pwd)/myapp.app I get a terminal output while its running, and everything works fine.
When I double click on the app in finder to run it, I obviously don't have access to the console to see debugging, but in parts of the app that work fine in the GUI when I run from console (clicking on things, etc), it crashes the app when run by clicking on it.
I realise people don't know what the app is, and without seeing where in the app it crashes, they can't help me. What I am after is some ideas about debugging it, for instance:
Outputting logs to a text file and tailing the text file to watch as it is written to
Connecting a debugger to the application by the process, perhaps I can discover where it crashes. This doesn't sound straight forward
Is there a way to attach to a console of an application run like this to see what it is outputting?
Any ideas appreciated.
Thanks

Word COM in scheduled task on Windows Server

I have an application that uses COM to automate Word. It needs to run even when a user is not logged in. I achieved this on Windows 7 by making it run as a scheduled task which runs at startup and doesn't require a user to be logged on. I also had to use the 'hack' where you add a 'Desktop' folder in 'C:/Windows/SysWow64/config/systemprofile'.
I tried this same method in Windows Server 2012, but it doesn't work. I can see in the task scheduler that the application is starting an instance of Word. However, it then appears to 'hang' and nothing happens. I think perhaps the invisible instance of Word is showing an error message which causes the whole thing to hang, as I cannot dismiss the message.
Has anyone else had trouble getting COM to work on windows server? Is there any way of showing hidden instances of Word to see if an error dialog is showing? Or any other way of diagnosing what the problem is?
I know ideally we would have an app that created the word documents without using COM, but this is not an option at the moment.
Does your app work when run as a logged-in user?
In the past I've run into what sound like similar problems, when running programs that try to use COM interfaces; some tasks work, but others simply don't function unless run as a logged-in user with an interactive desktop.
For me the simplest solution was to set up the machine to log in as a user at boot (which you can set up in the control panel - or I think there might also be a sysinternals tool that supports configuring that nowadays), then make sure that task scheduler/Jenkins/whatever you use launches the app as the logged-in user.

How can I know how my app was launched on Mac OS?

I've got a problem, and have been looking for a solution for a long time.
I made a application which has an option which will launch the app automatically when the system starts using Launch Services.
If application is launched by the user (ie. opening the .app) I want to do something.
If application is launch by Launch Services when the system starts I want to do another thing.
So I need to know how the app was launched: by the System (Launch Services loading the app when the computer turns on) or User (User opening the .app in the Finder).
How can I get this information?
Any suggestions are weclome.
prethanks.

Resources