Windows Server 2012中的安装程序注册表访问 [英] installer registry access in windows server 2012

查看:508
本文介绍了Windows Server 2012中的安装程序注册表访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Installshield Basic MSI项目中有一个自定义操作,可以从注册表中查找SQL Server的版本。

I have a custom action in an Installshield Basic MSI project to find out the version of SQL Server from registry.

RegKey2012 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" & _
             "Microsoft SQL Server\MSSQL11.MSSQLSERVER\"
If RegKeyExists(RegKey2012) Then 
  WScript.StdOut.Write("2012") 
Else 
  WScript.StdOut.Write("2008R2") 
End If 

Function RegKeyExists(Key) 
  Dim oShell, entry 
  On Error Resume Next 
  Set oShell = CreateObject("WScript.Shell") 
  entry = oShell.RegRead(Key) 
  If Err.Number <> 0 Then 
    Err.Clear 
    RegKeyExists = False 
  Else 
    Err.Clear 
    RegKeyExists = True 
  End If 
End Function

安装程序在Windows 7计算机上可以正常工作。上面的脚本在Windows Server 2012计算机上可以正常运行。但是,当我在Windows Server 2012上运行安装程序(作为ADMIN)时,它无法按预期运行,并且错误说明为-无法找到注册表项。

The installer works fine on a Windows 7 machine. The above script works fine in isolation on a Windows Server 2012 machine. However when I run the installer (as ADMIN) on windows server 2012, it does not work as expected and the error description is - It cannot find the registry key.

任何想法。

推荐答案

strkey="HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\Setup" & Chr(34) &  " /v Version /reg:64"

Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("REG QUERY " & Chr(34) & strkey )

strText = objScriptExec.StdOut.ReadAll()
if (strText <> "") then
WScript.echo "2012"
else
WScript.echo "2008R2"
end if

结尾,请注意/ reg: line1中的64选项。没有它,它就无法工作。

Note the /reg:64 option in line1. Without that it was not working.

这篇关于Windows Server 2012中的安装程序注册表访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆