如何在 InnoSetup 脚本中检测我是否在终端服务器上安装?

发布于 2024-07-22 05:03:03 字数 257 浏览 14 评论 0原文

当程序安装在终端服务器上时,我的设置的行为应该略有不同。 我了解 GetSystemMetrics(SM_REMOTESESSION) 但据我所知,它只会告诉我是否在 RDP 会话中运行。 它不会捕获服务器管理员在本地登录以安装软件的情况,或者会吗?

检查终端服务器服务似乎也不可行,因为启用远程桌面后该服务也在工作站上运行。 我需要将其与允许多个并发登录会话的真正 TS 区分开来。

我没有检查任何其他服务或注册表项吗?

My setup should behave slightly differently when the program is installed on a Terminal Server. I know about GetSystemMetrics(SM_REMOTESESSION) but as far as I understood that will only tell me whether I'm running inside a RDP session. It would not catch the case where the server admin is logged on locally to install software, or would it?

Checking for the Terminal Server service does not appear to be viable either as that also runs on workstations when Remote Desktop has been enabled. I need to differentiate this from a true TS that allows multiple concurrent logon sessions.

Isn't there any other service or registry key that I check for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

别忘他 2024-07-29 05:03:03

这正是您所需要的:

检测是否安装了终端服务

请注意,除此之外,您还可以使用 GetVersion() 的值来确定您是否正在运行 NT。 如果不是 NT 则退出。

// Are we running Windows NT?
DWORD dwVersion = GetVersion();
if (!(dwVersion & 0x80000000)) {
    // Is it Windows 2000 or greater?
    if (LOBYTE(LOWORD(dwVersion)) > 4) {
        // Check with VerSetConditionMask() and VerifyVersionInfo()
        return ..;
    }
    else  {
        // Windows NT 4.0 or earlier. Check ProductSuite value in
        // HKLM\\System\\CurrentControlSet\\Control\\ProductOptions
        return ..;
    }
}

return false;

链接显示的是如果版本是Win2k以上则需要查询的代码

This is exactly what you need:

Detecting Whether Terminal Services Is Installed

Note that in addition to this you can use the value of GetVersion() to determine if you are at all running NT. If not NT then bail out.

// Are we running Windows NT?
DWORD dwVersion = GetVersion();
if (!(dwVersion & 0x80000000)) {
    // Is it Windows 2000 or greater?
    if (LOBYTE(LOWORD(dwVersion)) > 4) {
        // Check with VerSetConditionMask() and VerifyVersionInfo()
        return ..;
    }
    else  {
        // Windows NT 4.0 or earlier. Check ProductSuite value in
        // HKLM\\System\\CurrentControlSet\\Control\\ProductOptions
        return ..;
    }
}

return false;

The link shows the code you need to query if the version is Win2k or later

夏の忆 2024-07-29 05:03:03

感谢 Magnus Skog 提供的链接,我发现 InnoSetup 已经支持 GetWindowsVersionEx API 函数。 因此,我所要做的就是:

function IsRunningOnTS: Boolean;
var
  lWinVer: TWindowsVersion;
begin
  GetWindowsVersionEx(lWinVer);
  Result := (lWinVer.SuiteMask and VER_SUITE_TERMINAL) <> 0;
end;

我已经成功地针对以下场景进行了测试:

  • 本地登录到启用了 RDP 的 XP 工作站(返回False
  • 通过 RDP 远程登录到终端服务器(返回 True
  • 通过 RDP 远程登录到工作站(返回 False

我还没有机会在 TS 本地登录时进行测试。 当我有时会更新这篇文章。

Thanks to the link provided by Magnus Skog I discovered that InnoSetup already supports the GetWindowsVersionEx API function. Therefore all I had to do was this:

function IsRunningOnTS: Boolean;
var
  lWinVer: TWindowsVersion;
begin
  GetWindowsVersionEx(lWinVer);
  Result := (lWinVer.SuiteMask and VER_SUITE_TERMINAL) <> 0;
end;

I have successfully tested this for the following scenarios:

  • logged on locally to an XP workstation with RDP enabled (returns False)
  • logged on remotely to a Terminal Server via RDP (returns True)
  • logged on remotely to a workstation via RDP (returns False)

I did not yet have the opportunity to test while logged on locally on a TS. Will update this post when I have.

苏璃陌 2024-07-29 05:03:03

我猜这个问题可能有很多答案,但所有这些答案似乎都有点令人不满意。

例如,可能的情况有哪些:

  • 工作站,启用了 RDP(即启用了远程帮助的 XP)
  • 服务器,启用了 RDP(通过检查操作系统类型可以轻松区分工作站)

但是,具有 RDP 的服务器又如何呢?选项已启用,但未使用? 启用 RDP 选项的服务器怎么样,但管理员在控制台上安装您的软件,而一天中没有人通过 RDP 登录? 您将无法确定服务器是否实际在使用(RDP 方式)。

给你一个具体答案的最好方法是问为什么你需要确定这个? 如果您能够可靠地检测到这一点,您将启用或禁用哪种功能?

I'm guessing that this question has a potential for many answers, all of which will seem slightly unsatisfactory.

For instance, what are the possible scenarios:

  • Workstation, with RDP enabled (ie. XP with remote help enabled)
  • Server, with RDP enabled (easily distinguishable from a workstation by checking the OS type)

However, what about a server that has the RDP option enabled, but it isn't used? How about a server that has the RDP option enabled, but the administrator is installing your software at the console, at a time of day when nobody is logged in through RDP? You wouldn't be able to determine if the server is actually in use, RDP-wise, or not.

The best way to give you a concrete answer is to ask why you need to determine this? What kind of functionality will you enable or disable if you were able to reliably detect this?

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