RealBASIC 在默认操作系统控制台/终端上打开程序文件
为了使我的 Real Studio 应用程序可移植,我想让它使用默认的控制台/终端应用程序在 Mac、Windows 和 Linux 上打开可执行文件。我有一个字符串 s,它是可执行文件的文件名。到目前为止我已经做到了:
#If TargetMacOS
DIM sh As new Shell
sh.Execute "open " + GetFolderItem(s).ShellPath + " -a Terminal"
#EndIf
但是这如何在 Windows 和 Linux 上完成呢?对于 Linux,我可以使用 gnome-terminal
或 konsole
打开该文件吗?如果可以,我如何确定使用哪一个打开它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 Linux,您实际上可以使用 shell 来测试并使用“which”命令查看哪一个可用。如果两者都是,那么只需选择一个(或者可以使其由用户配置)
在 Windows 上,我不确定如何强制它在命令提示符中打开。
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.
执行此操作的最佳方法是在应用程序中设置首选项,以允许用户设置其控制台应用程序的文件夹项。没有其他方法可以真正了解他们将使用什么软件。每个平台可用的选项太多,无法在操作系统中设置默认值。
如果您正在寻找一种方法来查找默认 shell,可以通过 ENV 变量来获取。
例如,在控制台中输入
$SHELL
,它将返回默认 shell 的路径。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.