RealBASIC 在默认操作系统控制台/终端上打开程序文件

发布于 2024-10-09 19:19:52 字数 384 浏览 0 评论 0原文

为了使我的 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-terminalkonsole 打开该文件吗?如果可以,我如何确定使用哪一个打开它?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜宝宝 2024-10-16 19:19:52

对于 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.

夜访吸血鬼 2024-10-16 19:19:52

执行此操作的最佳方法是在应用程序中设置首选项,以允许用户设置其控制台应用程序的文件夹项。没有其他方法可以真正了解他们将使用什么软件。每个平台可用的选项太多,无法在操作系统中设置默认值。

如果您正在寻找一种方法来查找默认 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文