简体   繁体   English

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

[英]How do I detect whether I'm installing on a Terminal Server in an InnoSetup script?

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. 我知道GetSystemMetrics(SM_REMOTESESSION)但据我了解,这只会告诉我是否在RDP会话中运行。 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. 我需要将其与允许多个并发登录会话的真实TS区别开来。

Isn't there any other service or registry key that I check for? 我没有要检查的其他任何服务或注册表项吗?

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. 请注意,除此之外,您还可以使用GetVersion()的值来确定您是否正在运行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 链接显示了您需要查询的代码(如果版本是Win2k或更高版本)

Thanks to the link provided by Magnus Skog I discovered that InnoSetup already supports the GetWindowsVersionEx API function. 感谢Magnus Skog提供的链接,我发现InnoSetup已经支持GetWindowsVersionEx API函数。 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 ) 在本地启用RDP的XP工作站上登录(返回False
  • logged on remotely to a Terminal Server via RDP (returns True ) 通过RDP远程登录到终端服务器(返回True
  • logged on remotely to a workstation via RDP (returns False ) 通过RDP远程登录到工作站(返回False

I did not yet have the opportunity to test while logged on locally on a TS. 在本地登录TS时,我还没有机会进行测试。 Will update this post when I have. 我有的时候会更新这篇文章。

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) 启用RDP的工作站(即启用了远程帮助的XP)
  • Server, with RDP enabled (easily distinguishable from a workstation by checking the OS type) 启用RDP的服务器(可通过检查OS类型轻松与工作站区分开)

However, what about a server that has the RDP option enabled, but it isn't used? 但是,对于启用了RDP选项但未使用的服务器呢? 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? 在一天中没有人通过RDP登录的情况下,启用了RDP选项但管理员正在控制台上安装软件的服务器如何? You wouldn't be able to determine if the server is actually in use, RDP-wise, or not. 您将无法确定服务器是否实际在使用(RDP方式)。

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? 如果能够可靠地检测到此功能,将启用或禁用哪种功能?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM