Runprograme on big sur

Post bugreports for the Mac OSX version here
MBall
User
User
Posts: 11
Joined: Wed Dec 18, 2019 11:33 pm

Runprograme on big sur

Post by MBall »

Hi

After updating to Big Sur on Mac. I am finding that my app which used to open 'TextEdit' with the following line no longer works.

RunProgram(GetUserDirectory(#PB_Directory_Programs)+"TextEdit.app","","")

it appears to open 'textedit' briefly, then immediately closes it. and the return result also shows that it opened ok.

any ideas. or is this a bug?

I have tried opening different apps with RunProgram, but most seem to close immediately.
I have also noticed that if I do have an app the will successfully open using 'RunProgram', it would work when run from the IDE, but once my program is compiled it then runs into the same issue of closing down the programe that was opened with RunProgram".

it all used to work nicely before updating to Big Sur. So I assume this is where my problems are coming from.

I think all that made sense lol

Martin.
User avatar
Shardik
Addict
Addict
Posts: 1850
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Runprograme on big sur

Post by Shardik »

MBall wrote:After updating to Big Sur on Mac. I am finding that my app which used to open 'TextEdit' with the following line no longer works.

RunProgram(GetUserDirectory(#PB_Directory_Programs)+"TextEdit.app","","")

it appears to open 'textedit' briefly, then immediately closes it. and the return result also shows that it opened ok.

any ideas. or is this a bug?
I have experienced the same problem already but also on Mojave and Catalina. Which was your previous MacOS version?

I have experienced this problem in Finder when double-clicking on some files with the extension .Txt. The solution has always been to start TextEdit from Applications > TextEdit.app or from the TextEdit.app copied to the Dock. After launching TextEdit in one of these two ways, I opened the problematic text file using the menu option "Open..." and saved it with "Save". After this action in most cases it was possible again to open the problematic text file by double-clicking it in Finder.
MBall
User
User
Posts: 11
Joined: Wed Dec 18, 2019 11:33 pm

Re: Runprograme on big sur

Post by MBall »

Previous OS was Catalina. That just worked fine.
It's not just 'TextEdit' that opens and then immediately closes. using 'RunProgram' with other apps does the same thing.

Martin.
Wolfram
Enthusiast
Enthusiast
Posts: 533
Joined: Thu May 30, 2013 4:39 pm

Re: Runprograme on big sur

Post by Wolfram »

There are two way to use it.

Code: Select all

RunProgram("open", "/Applications/TextEdit.app","")
or

Code: Select all

RunProgram("/Applications/TextEdit.app/Contents/MacOS/TextEdit","","")
GetUserDirectory(#PB_Directory_Programs) returns /Users/yourName/Applications/ and this is not the path where the most applications are.
Normally on macOS the application are in /Applications and not inside the user specific application folder.
MBall
User
User
Posts: 11
Joined: Wed Dec 18, 2019 11:33 pm

Re: Runprograme on big sur

Post by MBall »

Hi Woldram.

Thank you for your response.

I've already tried both of those. but no joy. the example I posted, was the last one I tried in my code.

as I said previously, it works Pre 'Big Sur'. On 'Big Sur', the TextEdit app does open, but then immediately closes.

I get the same result with other apps too.

Martin.
User avatar
Shardik
Addict
Addict
Posts: 1850
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Runprograme on big sur

Post by Shardik »

MBall wrote:as I said previously, it works Pre 'Big Sur'. On 'Big Sur', the TextEdit app does open, but then immediately closes.
Do you have the same problem when double-clicking the file in Finder? If yes, have you tried my proposed solution already?
Shardik wrote:The solution has always been to start TextEdit from Applications > TextEdit.app or from the TextEdit.app copied to the Dock. After launching TextEdit in one of these two ways, I opened the problematic text file using the menu option "Open..." and saved it with "Save".
MBall
User
User
Posts: 11
Joined: Wed Dec 18, 2019 11:33 pm

Re: Runprograme on big sur

Post by MBall »

works fine when launched from finder.

it's not just TextEdit. Seems most apps start.
then immediately close.
User avatar
deseven
Enthusiast
Enthusiast
Posts: 297
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Runprograme on big sur

Post by deseven »

Like Wolfram already told you, your way of launching applications is wrong, no matter the macOS version.

Code: Select all

RunProgram(GetUserDirectory(#PB_Directory_Programs)+"TextEdit.app","","")
This would never work, even if you'll put your TextEdit to your /Users/user/Applications/ folder.

And you can't even rely on /Applications in general anymore, because it can be /System/Applications now. I suggest using that:

Code: Select all

RunProgram("open","-a TextEdit","")
RunProgram("open","-b com.apple.TextEdit","")
Or, in case you want to launch the needed app manually, use URLForApplicationWithBundleIdentifier method of NSWorkspace to get its real path.
MBall
User
User
Posts: 11
Joined: Wed Dec 18, 2019 11:33 pm

Re: Runprograme on big sur

Post by MBall »

ok. i'll try to explain again.

The application i launch using 'RunProgram' does actually start in the background. but the problem is, the launched application immediately closes, as if the OS is shutting it down for some reason.
collectordave
Addict
Addict
Posts: 1275
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Runprograme on big sur

Post by collectordave »

Wolfram wrote: Sun Mar 14, 2021 11:10 am There are two way to use it.

Code: Select all

RunProgram("open", "/Applications/TextEdit.app","")
or

Code: Select all

RunProgram("/Applications/TextEdit.app/Contents/MacOS/TextEdit","","")
GetUserDirectory(#PB_Directory_Programs) returns /Users/yourName/Applications/ and this is not the path where the most applications are.
Normally on macOS the application are in /Applications and not inside the user specific application folder.
Running BigSur and had the same problem used the suggestion above:-

Code: Select all

RunProgram("open", "-a TextEdit","")
and it worked first time just fine.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply