【问题标题】:I want to install VB6 on windows 10 OS. I need to work on VBP project so I have to install VB6 seamlessly我想在 Windows 10 操作系统上安装 VB6。我需要处理 VBP 项目,所以我必须无缝安装 VB6
【发布时间】:2016-11-05 06:37:54
【问题描述】:

我已经设置了VB6企业版,但无法完成安装。(Hang)

我已尝试通过以下链接安装程序:http://nuke.vbcorner.net/Tools/VisualStudio6Installer/tabid/93/language/it-IT/Default.aspx

上面安装的条件你需要准备好我没有的msdn图像文件。如何在 Windows 10 上安装 VB6?

【问题讨论】:

  • 所以你想知道如何盗版VB6?
  • 不,我有 VB6 安装文件,但有些没有安装?文件夹和所有内容都已创建,但安装程序在最后一刻挂起。
  • 如果安装程序挂起,可能是您选中了数据组件选项。确保未选中。

标签: visual-studio vb6 windows-10


【解决方案1】:

This 应该适合您,但请确保您通读所有 cmets,因为零字节文件似乎已停止在以后的构建中工作,因此其他人共享了一些解决方法。虽然老实说,如果它所做的只是停止重新启动,我不明白为什么这很重要。复制正文以防万一有一天链接失效。

停止重启

与我之前在 Windows 7 和 Windows 8 上安装 VB6 的教程一样,您需要创建一个名为 MSJAVA.DLL 的零字节文件。在 C:\Windows 中创建此文件将避免在安装结束时重新启动。如果您不熟悉如何创建零字节文件,只需单击该链接即可。

让我们开始吧

插入安装媒体后,您首先会注意到程序兼容性助手会弹出一个关于已知兼容性问题的警告。关闭它 - 我们需要手动运行安装程序。如果您关闭了自动运行,您会在运行安装程序时弹出此窗口。

导航到安装媒体,然后找到安装程序。右键单击 setup.exe,然后选择以管理员身份运行。很重要!安装程序需要进行一些注册表操作并在 Windows 中注册一些项目,如果没有必要的权限,将无法执行此操作。

只需单击“运行程序而不寻求帮助”选项,主设置向导就会启动。

前几个屏幕是常见的东西,你以前见过的东西:

  • 欢迎屏幕 - 让您有机会查看自述文件。只是 除非您真的想阅读,否则请点击下一步!
  • EULA - 是的,它是最终用户许可协议。滚动它,然后 在相应的单选按钮中表示您接受,然后单击 接下来。
  • 产品编号和用户 ID - 这是您输入用户名的位置, 公司名称和产品编号。填写您认为合适的字段,然后 点击下一步继续向导。
  • 安装什么 - 这里有两个选项; VB6 企业版,或服务器 应用程序。我选择第一个选项
  • 通用安装文件夹 - 我接受了这个默认值: C:\Program Files (x86)\Microsoft Visual Studio\Common
  • 欢迎和警告 - 版权保护,无法更新文件 正在使用等。点击继续继续
  • Visual Basic 6.0 Enterprise Setup - 这是实际安装的位置 开始安装 VB6。您的 PID 显示在屏幕上,并且您 如果您还没有写下来,请写下来。点击确定 继续

主要安装

在 ACM 设置的第一个屏幕上,将安装文件夹保留为默认值,然后单击自定义选项进行设置。下一个屏幕将是选项列表。

我不使用 SourceSafe,所以我清除了复选框。如果您使用 SourceSafe,请务必检查安装。

非常重要(编者注:见文末评论) - 清除数据访问复选框。如果不这样做,设置将在安装结束时挂起。不确定真正的原因,但理论上是安装程序正在尝试在不存在的服务上向 Windows 注册。清除数据访问复选框会停止此注册尝试。

单击继续以继续安装过程。此时,如果您没有在 C:\Windows 中创建空的 MSJAVA.DLL 文件,您将收到重新启动 Windows 提示。如果需要,请继续重新启动,我会等待。

无论如何,您都会获得一个 MSDN 安装向导。我拒绝这样做,因为无论如何网上都可以找到更多信息。

现在您将看到一个选项服务器设置对话框。如果您想安装 BackOffice、Visual SourceSafe Server 或 SNA 服务器,此时您有机会。我不使用这些项目,所以我只需点击下一步即可。

最后,我们进入向导的最后一个屏幕。取消选中立即注册复选框,然后单击完成。

第一次运行 VB6

您可以在通常的 Microsoft Visual Basic 6.0 程序组下的开始菜单中找到新的快捷方式。您可能很想立即启动它,并且可以。但是,您会收到一个关于自动化的严重错误,即访问注册表时出错。您可以忽略这个错误,但每次启动 VB6 时都会不断出错,并且某些与数据访问相关的项目将无法正常工作。

因此,要解决此问题,请右键单击开始菜单组中的 Microsoft Visual Basic 6.0 程序图标,然后选择以管理员身份运行。在出现的 UAC 对话框中单击“是”,VB6 将正常启动,显示新项目向导。

好的,第一个后期设置任务完成。现在进入最后一部分。

修复 IDE Chug

现在,在您开始构建新项目或编辑现有项目之前,您可能还需要进行一些配置。在 Windows 10 虚拟机中运行 IDE 时,我发现 IDE 在调整和/或在表单上放置控件以及调整表单本身的大小时有些迟缓。这个问题也出现在 Windows 7 和 Windows 8 中。我们需要配置一些关于 IDE 的运行属性的东西来解决这个问题。

确保 IDE 已关闭,然后再次右键单击开始菜单图标。这次选择打开文件位置。

在出现的资源管理器窗口中,右键单击 Microsoft Visual Basic 6.0 图标,然后选择属性。在“属性”窗口中,选择“兼容性”选项卡。在“兼容性”选项卡上,单击“更改所有用户的设置”按钮。

在新的 VB6 属性窗口中,勾选以兼容模式运行此程序:复选框,然后从下拉列表中选择 Windows XP (Service Pack 3)。

在设置下,选中缩减颜色模式复选框,然后将下拉菜单更改为 16 位 (65536) 颜色。

勾选高 DPI 设置时禁用显示缩放。

单击确定,然后再次单击确定。

使用数据访问安装(截至 2016 年 7 月 3 日的最后评论)

我成功安装了 Visual Studio 6 Professional Windows 10 Pro 64 位带数据访问。很简单,只要 在启用数据访问的情况下像往常一样安装 VS6,它将 当您尝试完成安装时冻结。让它冻结,然后 结束安装任务。您仍将拥有所有安装文件 并且将能够运行该程序。现在,您将需要安装 VB6 service pack 6,但它不允许你因为 Visual Studio 没有正确安装。要解决此问题,请重新安装 VS6,这 时间取消选中数据访问组件,正常安装。之后, 运行服务包,您应该一切顺利。

【讨论】:

  • 当你尝试运行它时它会给你什么错误?
  • 它显示另一个版本的 Visual Studio 已安装您要设置程序吗?单击:是的,它完成了设置,最后一个消息窗口提到“设置正在更新文件”,并且在我通过任务管理器终止进程之前,此对话框永远不会关闭。嘘!!!!
  • 我记得当我在 Win 7 上设置它时,我读到 VB6 必须在任何其他 VS 版本之前安装,所以这就是我所做的。他的说明是在一台干净的机器上,所以如果安装了较新的版本,可能真的会出现问题。但是,我记得每当我打开 VB6 来处理一个项目时,我都会看到这个错误或一个非常接近它的错误,除非我只是取消它,一切都会正常工作。我不确定是什么原因造成的,但几个月后它就停止了,但我不知道发生了什么变化。
  • 最后我创建了XP的VM并在VM中安装了VB!解决方法!!! .感谢您的回复顺便说一句
  • 这些(40 磅头)是我们商店在 Windows 10 上安装 VB6 IDE 时使用的说明。
【解决方案2】:

我按照here 的说明为 Windows 10 创建了 VB 6 和 VB6 SP6 安装程序。

创建简单快速,并且工作起来没有问题。

【讨论】:

  • 您可能应该在该过程中添加一般步骤,或者至少添加一行关于重新创建安装程序的技巧。
【解决方案3】:

通过关注 Internet 上的许多帖子,我得到了在 Windows 10 下运行的 VS6/VB6,这些帖子涉及 1)降低 UAC + REGEDIT 检查,2)从 VS 安装磁盘 1 IE4 文件夹(un-7-压缩 MSJAVX86.EXE)将 MSJAVA.DLL 拖到所有 Windows SYSTEM32/SYSWOW64 文件夹(零字节 MSJAVA.DLL 不再起作用),3)放置和 REGSVR32'ing dx7vb.dll(在与上一步相同的文件夹中),然后使用 MSCONFIG 在安全模式下启动 Win10,并从原始 MSDN CD 运行安装。 [没有CD?继续阅读]

对于 VB6,您只需要 DISC 1、MSDN CD 和 Service Pack 6(从 Internet 上获取)。警告: DISC 1 的安装将变为“无响应”。就我而言,一个小时后,我认为它必须完成,所以让 Win10 将其作为“无响应窗口”关闭,然后它继续使用 MSDN 并且它工作。 (您也可以稍后从 CD 中独立安装 MSDN)如果您无法让 SP6 更新工作,请尝试将其放在根目录中的拇指驱动器上并调用卷名称 VS6SP6。事实上,对于 VB6,如果您没有 CD,您可以使用每个安装文件夹的内容创建 CD,前提是您提供 CD 卷标名称,如下所示:

VB6 光盘 1 卷标:VSP600ENU1

VB6 Disc 3 卷标:DN600ENU1

VB6 Disc 4 卷标:DN600ENU2

完成后,将 MSCONFIG 恢复为正常启动,然后将 UAC 重新启动。

一个小故障,我还没有修复。 Windows 10 不支持“.HLP”文件,因此没有可用的 VB6 帮助(即 MSDN)。但是,我已经阅读(但未尝试过)我可以将 WINHLP32.EXE 从 XP 机器复制到 Win10 Windows 目录。但首先我得让我的旧 XP 机器运行起来。

目前,我正在 Windows 10 家庭版下重新开发我所有的 VB 程序(没有 HELP 工具),并且可以再次进行编译!

希望这会有所帮助。

【讨论】:

    【解决方案4】:

    更新我上面关于帮助工具的帖子。即使我使用 CD 安装了 MSDN 库并从 XP 机器复制了一个旧的 winhlp32.exe,这允许我从 Win10 查看“.HLP”文件,但在 VB6 中没有任何帮助。最后,我能够访问该网站并下载 vshelp.exe。

    http://download.cnet.com/Visual-Studio-Help-Engine-for-MSDN-Enables-MSDN-menu-functionality-in-Visual-FoxPro/3000-2213_4-10727794.html

    它一闪而过,使所有 Visual Studio / Visual Basic 6.0 帮助工作,包括上下文相关帮助。

    【讨论】:

      【解决方案5】:

      微软对VB6编程环境的支持声明在这里... VB6 support statement

      【讨论】:

      • VB6 IDE 在 Windows 10 上运行良好。
      【解决方案6】:

      用于安装 VB6 编程 IDE 和 MSDN 库的 VB6 安装向导 Visual Studio 6.0 Installer wizard 已被下载超过 175,000 次。

      您需要有您的 VB6 或 VS6 CD 以及您的 VB6 序列号。

      它适用于 Windows 7、8.x 或 10 32 位或 64 位。

      【讨论】:

        【解决方案7】:

        我不久前制作了这个脚本,因为我在使用互联网上找到的安装程序和修复程序时遇到了问题。它将我在互联网上找到的所有技巧和技巧整合到一个 powershell 脚本中。

        要运行脚本,您需要执行以下操作:

        上面的每一个都应该放在自己的文件夹中。如果您将脚本保存(然后点源)在包含这三个文件夹的文件夹中,它将自动为您检测所有内容。您还可以将您在 powershell 中的当前位置设置为该文件夹并将脚本直接复制到您的会话中,它也会检测到所有内容。

        一旦脚本被点源或粘贴到提升的 Powershell 实例中,您可以通过调用 Install-VB6 来运行它。

        如果您想覆盖任何默认行为,它还具有以下参数:

        Parameter Type Usage
        Vb6InstallerPath String Path of main VB6 Installer folder
        SP6InstallerPath String Path of Service Pack 6 Installer folder
        SkipMouseWheel Switch Skip installing the Mouse Wheel Fixer folder
        MouseWheelPath String Path of Mouse Wheel fixer. Ignored if -SkipMouseWheel is specified
        Regsvr32Path String Path to regsvr32.exe. Uses '%SYSTEMROOT%\SysWoW64\regsvr32.exe' if not specified
        RegEditPath String Path to regedit.exe. '%SYSTEMROOT%\regedit.exe' if not specified
        OrganizationName String Sets the organization name in the VB6 installer

        注意事项:

        1. VB6 和 SP6 安装程序不喜欢从网络驱动器运行,因此如果检测到安装文件夹之一不在本地驱动器上,脚本将停止。
        2. 我只用 VB6 Pro 测试过这个,而不是 VB6 Enterprise。
        3. 它不安装 MSDN。

        安装-VB6.ps1

        #Requires -RunAsAdministrator
        #Requires -Version 3
        
        <#
        .SYNOPSIS
        Installs VB6 to the computer.
        
        .DESCRIPTION
        Installs VB6 ide with Service Pack 6 and (optional) Mouse Wheel Fix to the local computer.
        
        .PARAMETER Vb6InstallerPath
        The path to the VB6 installer folder.
        
        .PARAMETER SP6InstallerPath
        The path the the Service Pack 6 installer folder.
        
        .PARAMETER SkipMouseWheel
        Skip installing the Mouse Wheel fix.
        
        .PARAMETER MouseWheelPath
        The path the Mouse wheel fix folder.
        
        .PARAMETER Regsvr32Path
        The path to RegSvr32.exe
        
        .PARAMETER OrganizationName
        The organization name
        
        .PARAMETER RegEditPath
        The path to regedit.exe
        #>
        Function Install-VB6{
            [CmdletBinding()]
            param (
                [Parameter(Mandatory=$false)]
                [string]$Vb6InstallerPath,
                [Parameter(Mandatory=$false)]
                [string]$SP6InstallerPath,
                [Parameter(Mandatory=$false)]
                [switch]$SkipMouseWheel,
                [Parameter(Mandatory=$false)]
                [string]$MouseWheelPath,
                [Parameter(Mandatory=$false)]
                [string]$Regsvr32Path,
                [Parameter(Mandatory=$false)]
                [string]$OrganizationName,
                [Parameter(Mandatory=$false)]
                [string]$RegEditPath
            )
        
        
            # Tests if the path is a local path. The installer doesn't like network paths.
            function Test-LocalDrive{
                [CmdletBinding()]
                [OutputType([bool])]
                param(
                    [Parameter(Mandatory=$true,
                                Position=0)]
                    [string]$Path
                )
                begin{
                    $localDrives = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType<>4" -Property "DeviceID" | Foreach-Object {$_.DeviceID.Replace(":", "")}
                }
                process{
                    if(!([bool](Test-Path -Path $Path))){
                        return $false
                    }
        
                    $item = Get-Item -Path $Path
                    $drive = $item.PSDrive
        
                    if($null -eq $drive){
                        return $false
                    }
        
                    return ($localDrives -contains $drive.Name)
                }
            }
        
            function Search-ForFile{
                [CmdletBinding()]
                [OutputType([System.IO.FileInfo])]
                param(
                    [Parameter(Mandatory=$true,
                                Position=0)]
                    [string]$File,
                    [Parameter(Mandatory=$true,
                                Position=1)]
                    [string]$CurrentLocation,
                    [switch]$IncludeSubDirectory
                )
                process{
                    $newPath = $currentLocation
                    if($IncludeSubDirectory.IsPresent){
                        $newPath = Join-Path -Path $newPath -ChildPath "*"
                    }
                    $newPath = Join-Path -Path $newPath -ChildPath $file
        
                    $item = @(Get-Item -Path $newPath)
        
                    if($null -eq $item -or $item.Count -eq 0 -or $null -eq $item[0]){
                        throw ("Could Not find the {0} file." -f $file)
                    }
        
                    return $item[0]
                }
            }
        
            
        
        #region Setting Up File Paths
            $currentLocation = $PSScriptRoot
            if([System.String]::IsNullOrWhiteSpace($currentLocation)){
                $currentLocation = (Get-Location)
            }
            if([System.String]::IsNullOrWhiteSpace($currentLocation)){
                throw "Unable to determine current location"
            }
        
            if(!$PSBoundParameters.ContainsKey("Vb6InstallerPath") -or [System.String]::IsNullOrWhiteSpace($Vb6InstallerPath)){
                if(!(Test-LocalDrive -Path ($currentLocation))){
                    Write-Error "The script cannot be ran from a network share."
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
                $installerInfo = Search-ForFile -File "SETUP.EXE" -CurrentLocation $currentLocation -IncludeSubDirectory
                $installFolder = $installerInfo.DirectoryName
            }
            else {
                if(!(Test-LocalDrive -Path ($Vb6InstallerPath))){
                    Write-Error "The VB6 Installer Path cannot be a share."
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
                $installFolder = $Vb6InstallerPath
                $installerInfo = Search-ForFile -File "SETUP.EXE" -CurrentLocation $installFolder
            }
        
            $installer2Info = Search-ForFile -File "ACMSETUP.EXE" -CurrentLocation $installFolder -IncludeSubDirectory
        
            $installLocation = $installerInfo.FullName
            $install2Location = $installer2Info.FullName
        
            if(!$PSBoundParameters.ContainsKey("SP6InstallerPath") -or [System.String]::IsNullOrWhiteSpace($SP6InstallerPath)){
                if(!(Test-LocalDrive -Path ($currentLocation))){
                    Write-Error "The script cannot be ran from a network share."
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
                $SP6Info = Search-ForFile -File "setupsp6.exe" -CurrentLocation $currentLocation -IncludeSubDirectory
                $SP6Folder = $SP6Info.DirectoryName
            }
            else {
                if(!(Test-LocalDrive -Path ($SP6InstallerPath))){
                    Write-Error "The SP6 Installer Path cannot be a network share."
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
                $SP6Folder = $SP6InstallerPath
                $SP6Info = Search-ForFile -File "setupsp6.exe" -CurrentLocation $SP6Folder
            }
        
            $SP6Location = $SP6Info.FullName
        
            if(!$SkipMouseWheel.IsPresent){
                if(!$PSBoundParameters.ContainsKey("MouseWheelPath") -or [System.String]::IsNullOrWhiteSpace($MouseWheelPath)){
                    if(!(Test-LocalDrive -Path ($currentLocation))){
                        Write-Error "The script cannot be ran from a network share."
                        Write-Host -NoNewLine 'Press any key to continue...';
                        $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                        return
                    }
                    $MouseWheelDllInfo           = Search-ForFile -File "VB6IDEMouseWheelAddin.dll" -CurrentLocation $currentLocation -IncludeSubDirectory
                    $MouseWheelRegistryInfo      = Search-ForFile -File "VBA Mouse Wheel Fix.reg" -CurrentLocation $currentLocation -IncludeSubDirectory
                }
                else {
                    if(!(Test-LocalDrive -Path ($SP6InstallerPath))){
                        Write-Error "The Mouse Wheel Path cannot be a network share."
                        Write-Host -NoNewLine 'Press any key to continue...';
                        $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                        return
                    }
                    $MouseWheelDllInfo           = Search-ForFile -File "VB6IDEMouseWheelAddin.dll" -CurrentLocation $MouseWheelPath
                    $MouseWheelRegistryInfo      = Search-ForFile -File "VBA Mouse Wheel Fix.reg" -CurrentLocation $MouseWheelPath
                }
        
                $MouseWheelDll           = $MouseWheelDllInfo.FullName
                $MouseWheelRegistry      = $MouseWheelRegistryInfo.FullName
            }
        
            if(!$PSBoundParameters.ContainsKey("Regsvr32Path") -or [System.String]::IsNullOrWhiteSpace($Regsvr32Path)){
                $regSvrPath = "$($env:systemroot)\SysWoW64\regsvr32.exe"
            }
            else{
                $regSvrPath = $Regsvr32Path
            }
        
            if(!$PSBoundParameters.ContainsKey("RegEditPath") -or [System.String]::IsNullOrWhiteSpace($RegEditPath)){
                $RegEditPath = "$($env:systemroot)\regedit.exe"
            }
        #endregion Setting Up File Paths
        
        #region Test Required Installer Paths Exist
        
            if(!([bool](Test-Path -Path $regSvrPath))){
                Write-Error ("Unable to find '{0}'.`r`nThe exe must exist." -f $regSvrPath)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
            if(!([bool](Test-Path -Path $RegEditPath))){
                Write-Error ("Unable to find '{0}'.`r`nThe exe must exist." -f $RegEditPath)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
            if(!$SkipMouseWheel.IsPresent){
                if(!([bool](Test-Path -Path $MouseWheelDll))){
                    Write-Error ("Unable to find '{0}'.`r`nThe 'MouseWheel' Folder must be in the same directory as the install script and the file must exist." -f $MouseWheelDll)
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
        
                if(!([bool](Test-Path -Path $MouseWheelRegistry))){
                    Write-Error ("Unable to find '{0}'.`r`nThe 'MouseWheel' Folder must be in the same directory as the install script and the file must exist." -f $MouseWheelRegistry)
                    Write-Host -NoNewLine 'Press any key to continue...';
                    $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                    return
                }
            }
        
            if(!([bool](Test-Path -Path $installFolder))){
                Write-Error ("Unable to find '{0}'.`r`nThe 'Installer' Folder must be in the same directory as the install script." -f $installFolder)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
            if(!([bool](Test-Path -Path $installLocation))){
                Write-Error ("Unable to find '{0}'.`r`nThe 'Installer' Folder must be in the same directory as the install script and the file must exist." -f $installLocation)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
            if(!([bool](Test-Path -Path $install2Location))){
                Write-Error ("Unable to find '{0}'.`r`nThe 'Installer' Folder must be in the same directory as the install script and the file must exist." -f $install2Location)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
            if(!([bool](Test-Path -Path $SP6Location))){
                Write-Error ("Unable to find '{0}'.`r`nThe 'SP6' Folder must be in the same directory as the install script and the file must exist." -f $SP6Location)
                Write-Host -NoNewLine 'Press any key to continue...';
                $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
                return
            }
        
        #endregion Test Required Installer Paths Exist
        
        #region Installer Compatibility
            # The installer doesn't auto-elevate to run as an administrator.
            # We are setting the required keys in the registry to force the installers to run as administrator
            # Same as running the 'troubleshoot compatibilty' wizard and selecting the exe's to run as admins.
            Write-Host "Setting compatibility mode on setup files."
            $layersPath = "REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
            if(![bool](Test-Path -Path $layersPath)){
                New-Item -Path $layersPath -Force | Out-Null
            }
        
            $registryPath = Get-Item -LiteralPath $layersPath
            if($null -eq $registryPath.GetValue($installLocation, $null)){
                New-ItemProperty -Path $layersPath -Name $installLocation -Value "^ WINXPSP3" -PropertyType "String" -Force | Out-Null
            }
        
            if($null -eq $registryPath.GetValue($SP6Location, $null)){
                New-ItemProperty -Path $layersPath -Name $SP6Location -Value "^ WINXPSP3" -PropertyType "String" -Force | Out-Null
            }
        #endregion Installer Compatibility
        
        #region Previous Install Cleanup
            # Locations and keys where old vb6 installs can live.
            Write-Host "Cleaning up previous install."
        
            $itemsToDelete = @(
                "C:\Program Files*\Microsoft Visual Studio\Common",
                "C:\Program Files*\Microsoft Visual Studio\MSDN",
                "C:\Program Files*\Microsoft Visual Studio\MSDN98",
                "C:\Program Files*\Microsoft Visual Studio\VB98",
                "C:\Program Files*\Microsoft Visual Studio\VC98",
                "C:\Program Files*\Microsoft Visual Studio\*.HTM",
                "C:\Program Files*\Microsoft Visual Studio\*.TXT",
                "C:\Program Files*\Common Files\Microsoft Shared\MSDesigners98",
                "C:\Program Files*\Common Files\Microsoft Shared\MSDN",
                "C:\Program Files*\Common Files\Microsoft Shared\VS98",
                "C:\Program Files*\Common Files\Microsoft Shared\Wizards98",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\DevStudio",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\HTML Help Collections",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\MSVSDG",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Visual Basic\6.0",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Visual Component Manager",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Visual Modeler",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\DevStudio",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\HTML Help Collections",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\MSVSDG",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Visual Basic\6.0",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Visual Component Manager",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Visual Modeler",
                "REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\6.0",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\DevStudio",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\MSVSDG",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\Visual Modeler",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro",
                "REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\6.0"
            )
        
            $itemsToDelete | Where-Object { Test-Path -Path $_ } | Remove-Item -Force -Recurse | Out-Null
        #endregion Previous Install Cleanup
        
        #region Installer Registry Permissions
            # The installer needs to be able to write to 'HKEY_CLASSES_ROOT\RDSServer.DataFactory\Clsid'
            # but since the installer isn't built for windows and we have to force it to run as an administrator
            # we have to give explicit permissions for your computers Administrators group to write to this key (and all its children)
            Write-Host "Setting required permissions for installing user on registry."
        
            $registryPermissionPath = "REGISTRY::HKEY_CLASSES_ROOT\RDSServer.DataFactory\Clsid"
            Write-Host "`tSetting Up required information."
            $acl = Get-ACL -Path $registryPermissionPath
            $oldOwner = [System.Security.Principal.NTAccount]::new($acl.Owner)
            $administratorIdentity = [System.Security.Principal.NTAccount]::new("Administrators")
        
            Write-Host "`tGiving the script required permissions."
            $import = '[DllImport("ntdll.dll")] public static extern int RtlAdjustPrivilege(ulong a, bool b, bool c, ref bool d);'
            $ntdll = Add-Type -Member $import -Name NtDll -PassThru
            $privileges = @{ SeTakeOwnership = 9; SeBackup =  17; SeRestore = 18 }
            foreach ($i in $privileges.Values) {
                $null = $ntdll::RtlAdjustPrivilege($i, 1, 0, [ref]0)
            }
        
            Write-Host "`tGettting The registry key."
            $regKey = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("RDSServer.DataFactory\Clsid", 'ReadWriteSubTree', 'TakeOwnership')
        
            # We force the Administrators group to be the owner on the key so we can then add required the permissions.
            Write-Host "`tSetting Owner."
            $acl.SetOwner($administratorIdentity)
            $regKey.SetAccessControl($acl)
        
            Write-Host "`tSetting Permission."
            $permission = [System.Security.AccessControl.RegistryAccessRule]::new($administratorIdentity, "FullControl", "ContainerInherit", "InheritOnly", "Allow")
            $acl.AddAccessRule($permission)
            $permission2 = [System.Security.AccessControl.RegistryAccessRule]::new($administratorIdentity, "FullControl", "Allow")
            $acl.AddAccessRule($permission2)
            $regKey.SetAccessControl($acl)
        
            # Reset the owner to clean-up
            Write-Host "`tResetting Owner."
            $acl.SetOwner($oldOwner)
            $regKey.SetAccessControl($acl)
        
        #endregion Installer Registry Permissions
        
        #region Install
            Write-Host "`tStarting Install."
            $tempPath = [System.IO.Path]::GetTempPath()
            $tempFolder = Join-Path -Path $tempPath -ChildPath ([System.Guid]::NewGuid().ToString("n"))
            New-Item -Path $tempFolder -ItemType Directory -Force | Out-Null
            $KeyFile = Join-Path -Path $tempFolder -ChildPath ("{0}.dat" -f [System.Guid]::NewGuid().ToString("n"))
            $keyFileText = @"
        REGEDIT4
        
        [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic\SetupWizard]
        "aspo"=dword:00000000
        
        [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic\SetupWizard]
        "aspo"=dword:00000000
        "@
            $keyFileText | Set-Content -Path $keyFile -Force
        
            & $RegEditPath /S $KeyFile
            
            [string[]]$installerArguments = ("/T", "VB98PRO.stf", "/S", $installFolder, "/n", ($env:USERNAME), "/k", "0000000000", "/b", "1", "/qn1")
        
            if($PSBoundParameters.ContainsKey("OrganizationName") -and ![System.String]::IsNullOrWhiteSpace($OrganizationName)){
                $installerArguments += "/o"
                $installerArguments += $OrganizationName
            }
            Start-Process -FilePath $install2Location -wait -NoNewWindow -ArgumentList $installerArguments
            Start-Process -FilePath $SP6Location -wait -NoNewWindow -ArgumentList ("/qn1")
        
            Write-Host "Setting Vb6 Compatibility"
            $vb6ExeLocations = @(Get-Item -Path "C:\Program Files*\Microsoft Visual Studio\VB98\VB6.EXE" | Select-Object -ExpandProperty FullName)
            $registryPath = Get-Item -LiteralPath $layersPath
            foreach($vb6ExeLocation in $vb6ExeLocations){
                if($null -eq $registryPath.GetValue($vb6ExeLocation, $null)){
                    New-ItemProperty -Path $layersPath -Name $vb6ExeLocation -Value "^ WINXPSP3" -PropertyType "String" -Force | Out-Null
                }
            }
        
            if(!$SkipMouseWheel.IsPresent){
        
                Write-Host "Installing Mouse Wheel"
                & $regSvrPath /s $MouseWheelDll
                & $RegEditPath /S $MouseWheelRegistry
        
                $registryHeaderText = @"
        Windows Registry Editor Version 5.00
        
        
        "@
        
                $registryItemFormat = @"
                [{0}\SOFTWARE\Microsoft\Visual Basic\6.0\Addins\VB6IDEMouseWheelAddin.Connect]
                "FriendlyName"="MouseWheel Fix"
                "LoadBehavior"=dword:00000003
                "CommandLineSafe"=dword:00000000
        "@
        
                $users = Get-ChildItem -Path "REGISTRY::HKEY_USERS" | Where-Object {$_.Name -notlike "*_Classes"} | Select-Object -ExpandProperty Name
                $content = $registryHeaderText
        
                # Install for every user.
                foreach($user in $users){
                    $content += ($registryItemFormat -f $user)
                }
        
                $MouseWheelApplyRegistry = Join-Path -Path $tempFolder -ChildPath ("{0}.reg" -f [System.Guid]::NewGuid().ToString("n"))
        
                $content | Set-Content -Path $MouseWheelApplyRegistry -Force
                Start-Process $RegEditPath -wait -NoNewWindow -ArgumentList ("/S", $MouseWheelApplyRegistry)
        
                Write-Host "You will still need to enable Mouse Wheel fix in the VB6 IDE." -BackgroundColor Black -ForegroundColor Red
                Write-Host "Open a Visual Basic project and go to 'Add-Ins' -> 'Add-In Manager...' " -BackgroundColor Black -ForegroundColor Red
                Write-Host "Select 'MouseWheel Fix' and click 'Loaded/Unloaded' and 'Load on Startup'"  -BackgroundColor Black -ForegroundColor Red
            }
        
            Remove-Item -Path $tempFolder -Force -Recurse | Out-Null
        #endregion Install
        
            Write-Host "Install Complete"
            Write-Host -NoNewLine 'Press any key to continue...';
            $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
        }
        

        【讨论】:

          猜你喜欢
          • 2019-01-30
          • 2017-06-01
          • 2012-05-16
          • 1970-01-01
          • 2018-05-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多