Move App to Applications Folder

Greetings,

Is there a way to automatically move the app to applications folder on first run ?

I need the following workflow

  1. Start the app anywhere in the Mac
  2. Move the app to Applications Folder and restart the app from the new location.

And to be done natively if possible in the app.

Thanks.

Thatā€™s what an installer does or (manually a DMG file you are providing). Most users would not like that someone is moving whatsoever automatically into their app filter.

1 Like

well in this case they will and it is a mandatory option so I guess the best way to doit would be a helper or something doing that.

You will be amazed to see a lot of users just double clicking on the app in the DMG and not even moving it to the apps folder so dumping the app anywhere in the Mac and then searching for it so trying to avoid all this mess by putting it in the right place where it should be.

Yes, I understand where you are coming from. Issue is that Apple sees this differently and suggests using an installation tool for that. But it is uncommon that you are starting an app and that this app will copy itself or other stuff into the app folder ā€¦ and chances are very high that Apple will be even more restrictive on what will be possible in future and what not. I personally suggest not starting that fight ;-). If this a business app (more than a family & friends app) you should follow the guidelines. https://www.ohanaware.com/appwrapper/ gives you a good starting point for more information, notarization, sandbox, etc.

I have seen many apps copy themselves to the Applications folder when launched for the first time.
Unfortunately I do not know how to do it.

In the old days I did notice myself, but recently? I am not aware of any program copying itself ā€¦ unless it is installing itself via pkg ā€¦ but this is not saying that Iā€™m right. Perhaps pure coincidence

And then provides an installer that happily installs a new version into the Trash, if that is where you dragged a previous version before installing the new one.
Or installs into iCloud if it finds an old copy of the app over there.

At least with a DMG, they drag the app into Applications.
If they only double click while in the DMG, thatā€™s ā€˜OKā€™ ā€¦ no install has to happen, but it may run slowly.

1 Like

yup, Iā€™m only using DMG for my Apps. I am suspicious when Iā€™m seeing an installer ā€¦ if not from a big brand it is almost always rubbish on macOS :frowning: and doing silly things.

1 Like

thanks guys, for us is a special case and the app must be in Applications folder and 80 % of the users donā€™t even move the app in the DMG even if they have clear instructions to do so, they simply double click on it and the app itself has to be in Applications folder for many reasons so because we donā€™t do MAS I care less about Apple guidelines and I do what I need to do and done.

Thanks again and if I find a way Iā€™ll post it here

Create a shell script in the application support folder that does the copy. The script can also restart the app.

1 Like

Just to be clear, MAS is not the only place where this is important. Applications that are not dragged to Applications are quarantined in recent versions of macOS and will run in a restricted way anyway.

It might be simpler to detect where the app is running from and refuse to launch if the app isnā€™t in /Applications.

3 Likes

Hit me up in a few days if I forget, but it is possible.

1 Like

You can check Application.Executablefile, and if the app is not in /Applications, launch a shell from within the application, copying itself in SpecialFolder.Applications.

Sub Open() Handles Open
  Dim f As folderitem = app.ExecutableFile.parent.parent.Parent
  
  If f.ShellPath.IndexOf("/Applications") <> 0 Then
Dim s as new shell
Dim cmd As String = "cp -R "+ f.shellpath + " /Applications/"
s.Execute(cmd)
  End If
  
End Sub
1 Like

The applications I know that copy themselves to the Applications folder all ask the user prior to do the copy. Iā€™d say it must be done.
If running from the Applications folder is mandatory, Iā€™d suggest the dialog to show ā€œThis application must be started from the ā€œApplicationsā€ folder. Would you like me to copy myself there?ā€ with buttons {ā€œCopy&restartā€,ā€œQuitā€}.

1 Like

I agree that good ethical business practice should endorse such a behavior. But I understood the OP that he has to deal with ā€œdumbā€ end users within a company or a restricted business context. In this case (but only in this case) I would agree that you can do nasty things, but I still prefert your way showing a popup and asking, but if users are to dumb to move a file from a dmg icon into the applications folder then there is little hope ā€¦ I know a very few similar customers ;-).

Even if the dialog mentions ā€œIt will be a great experience for you to move me in the apps folder! Enjoy by clicking this nice ā€œGet joy and move meā€ blue button below and youā€™ll be satisfied for the rest of your day!
You donā€™t have alternatives as I wonā€™t run otherwise, so do it and be pleased!ā€ would a user not do it, as dumb as (s)he can be?

1 Like

I have (unfortunately) seen the utmost incredible things. I currently have a customer ā€¦ opening tickets again, and again about similar topics. When she opens the app, she get a popup after 1 second if there is an update. She only needs to click it. Current version is 4.3.2. She ist using 3.8.9 ā€¦ sometimes I see little hope for the human race :slight_smile:

1 Like

Thanks Michel

well agree what you said as well but not in this case and it is a mandatory thing and taking in consideration that they hate popups the idea came from the users to avoid putting them in trouble so I guess this is what it will be done.

Well now you got my point :smile: