To make my Real Studio application portable, I want to make it open an executable file on Mac, Windows, and Linux with the default Console/Terminal application. I have a string s, which is the filename of the executable file. I have this so far:
#If TargetMacOS
DIM sh As new Shell
sh.Execute "open " + GetFolderItem(s开发者_高级运维).ShellPath + " -a Terminal"
#EndIf
But how can this be done on Windows and Linux? For Linux, could I open the file with gnome-terminal
or konsole
, and if so how could I figure out which one to open it with?
For linux you could actually use the shell to test and see which one is available using the "which" command. If both are then just pick one (or maybe make it user configurable)
On windows I'm not sure exactly how you'd force it to open in the command prompt.
The best way to do this is to setup preferences in your app to allow the user to set the folderitem of their console app. There is no other way to really know what software they will be using. There are too many options available to each platform and no way to set the default in the OS.
If your looking for a way to find the default shell, it is available through the ENV variable.
For example- type $SHELL
in your console and it will return the path to the default shell.
精彩评论