找回密码
 加入
搜索
楼主: msold5

[AU3基础] [已解决]PrimoCache4.3安装过程RUN运行程序出错?

[复制链接]
发表于 2023-9-10 01:30:42 | 显示全部楼层
测试可用代码。
#include <File.au3>
#include <WinAPIError.au3>
Global $Log = @ScriptDir & "\日志.log"
Global $path = @ProgramFilesDir & "\PrimoCache"
_drivers($path)

Func _drivers($Dir)
        $Pid = Run('"' & $Dir & "\fcsetup.exe" & '"' & ' -i ' & '"' & $Dir & "\drv\rxfcv.inf" & '"' & ' 257', $Dir, @SW_HIDE)
        ProcessWaitClose($Pid)
        $Handle = _ProcessExitCode($Pid)
        $ExitCode = _ProcessExitCode($Pid, $Handle)
        If $ExitCode <> 0 Then
                _FileWriteLog($Log, "驱动安装完成。 退出代码:" & $ExitCode & ":" & _WinAPI_GetErrorMessage($ExitCode))
        Else
                _FileWriteLog($Log, "驱动安装完成")
        EndIf
EndFunc   ;==>_drivers

Func _ProcessExitCode($i_Pid, $h_Process = 0)
        Local $v_Placeholder
        If Not IsArray($h_Process) Then
                $h_Process = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', 0x400, 'int', 0, 'int', $i_Pid)
                If Not @error Then Return $h_Process
        Else
                $h_Process = DllCall('kernel32.dll', 'ptr', 'GetExitCodeProcess', 'ptr', $h_Process[0], 'int*', $v_Placeholder)
                If Not @error Then Return $h_Process[2]
        EndIf
        Return 0
EndFunc   ;==>_ProcessExitCode
发表于 2023-9-10 01:39:56 | 显示全部楼层
这软件可以脱离原版自己安装的。
#AutoIt3Wrapper_UseX64=y
#NoTrayIcon
#include <File.au3>
#include <WinAPIError.au3>
Global $Log = @ScriptDir & "\日志.log"
Global $path = @ProgramFilesDir & "\PrimoCache"
If @OSBuild < 6001 Then Exit MsgBox(0, "错误", "不支持的操作系统.")
_install($path)
_TestCertificate($path & "\TestCertificate.cer")
_drivers($path)
_RegCache($path)
_FileWriteLog($Log, "安装完毕")



Func _install($Dir)
        If Not FileExists($Dir) Then DirCreate($Dir)
        If Not FileExists($Dir & "\drv") Then DirCreate($Dir & "\drv")
        If Not FileExists($Dir & "\lang") Then DirCreate($Dir & "\lang")
        FileInstall(".\Resources\FancyCcV.exe", $Dir & "\FancyCcV.exe", 1)
        FileInstall(".\Resources\fcsetup.exe", $Dir & "\fcsetup.exe", 1)
        FileInstall(".\Resources\rxpcc.exe", $Dir & "\rxpcc.exe", 1)
        FileInstall(".\Resources\TestCertificate.cer", $Dir & "\TestCertificate.cer", 1)
        FileInstall(".\Resources\unins000.exe", $Dir & "\unins000.exe", 1)
        FileInstall(".\Resources\unins000.dat", $Dir & "\unins000.dat", 1)
        FileInstall(".\Resources\pcc_chs.dll", $Dir & "\lang\pcc_chs.dll", 1)
        Select
                Case @OSBuild >= 6001 And @OSBuild < 10240
                        FileInstall(".\Resources\rxfcv,7.cat", $Dir & "\drv\rxfcv.cat", 1)
                        FileInstall(".\Resources\rxfcv,7.inf", $Dir & "\drv\rxfcv.inf", 1)
                        FileInstall(".\Resources\rxfcv,7.sys", $Dir & "\drv\rxfcv.sys", 1)
                        FileInstall(".\Resources\rxbsknl,7.sys", @SystemDir & "\drivers\rxbsknl.sys", 1)
                Case @OSBuild >= 10240
                        FileInstall(".\Resources\rxfcv,10.cat", $Dir & "\drv\rxfcv.cat", 1)
                        FileInstall(".\Resources\rxfcv,10.inf", $Dir & "\drv\rxfcv.inf", 1)
                        FileInstall(".\Resources\rxfcv,10.sys", $Dir & "\drv\rxfcv.sys", 1)
                        FileInstall(".\Resources\rxbsknl,10.sys", @SystemDir & "\drivers\rxbsknl.sys", 1)
                Case Else
        EndSelect
        If Not FileExists(@StartMenuCommonDir & "\PrimoCache") Then DirCreate(@StartMenuCommonDir & "\PrimoCache")
        FileCreateShortcut($Dir & "\FancyCcV.exe", @StartMenuCommonDir & "\PrimoCache\PrimoCache.lnk", $Dir)
        FileCreateShortcut($Dir & "\unins000.exe", @StartMenuCommonDir & "\PrimoCache\卸载PrimoCache.lnk", $Dir)

EndFunc   ;==>_install

Func _drivers($Dir)
        $Pid = Run('"' & $Dir & "\fcsetup.exe" & '"' & ' -i ' & '"' & $Dir & "\drv\rxfcv.inf" & '"' & ' 257', $Dir, @SW_HIDE)
        ProcessWaitClose($Pid)
        $Handle = _ProcessExitCode($Pid)
        $ExitCode = _ProcessExitCode($Pid, $Handle)
        If $ExitCode <> 0 Then
                _FileWriteLog($Log, "驱动安装完成。 退出代码:" & $ExitCode & ":" & _WinAPI_GetErrorMessage($ExitCode))
        Else
                _FileWriteLog($Log, "驱动安装完成")
        EndIf
EndFunc   ;==>_drivers

Func _TestCertificate($File)
        If Not FileExists($File) Then Return False
        RegRead("HKLM64\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates\D39680ED59502209941759C74229F7E2FAC72749", "Blob")
        If @error Then
                If FileExists(@SystemDir & "\certutil.exe") and FileExists($File) Then
                        RunWait(@SystemDir & "\certutil.exe" & " -f -addstore Root " & '"' & $File & '"', @ScriptDir, @SW_HIDE)
                        RunWait(@SystemDir & "\certutil.exe" & " -f -addstore TrustedPublisher " & '"' & $File & '"', @ScriptDir, @SW_HIDE)
                        _FileWriteLog($Log, "添加驱动证书")
                        FileDelete($File)
                Else
                        FileDelete($File)
                        Return False
                EndIf
        Else
                _FileWriteLog($Log, "驱动证书已存在")
                FileDelete($File)
        EndIf
        Return True
EndFunc   ;==>_TestCertificate

Func _RegCache($Dir)
        Local $iRegWrite, $Data, $Uninstall
        $Uninstall = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7A37EA43-BF6F-4DB7-83DB-97AA19BF9408}_is1"
        RegWrite("HKLM64\SOFTWARE\Romex Software\FancyCcV", "Version", "REG_DWORD", 67305472)
        RegWrite("HKLM64\SOFTWARE\Romex Software\FancyCcV", "Multilingual", "REG_SZ", "mui")
        RegWrite("HKLM64\SOFTWARE\Romex Software\FancyCcV", "PrefetchPath", "REG_SZ", "\DosDevices" & $Dir & "\prefetch")
        RegWrite("HKCU64\SOFTWARE\Romex Software\PrimoCache", "LanguageId", "REG_DWORD", 2052)

        RegWrite($Uninstall, "DisplayName", "REG_SZ", "PrimoCache 4.3.0")
        RegWrite($Uninstall, "DisplayVersion", "REG_SZ", "4.3.0")
        RegWrite($Uninstall, "UninstallString", "REG_SZ", $Dir & "\unins000.exe")
        RegWrite($Uninstall, "DisplayIcon", "REG_SZ", $Dir & "\FancyCcV.exe")
        RegWrite($Uninstall, "InstallLocation", "REG_SZ", $Dir & "")
        RegWrite($Uninstall, "Publisher", "REG_SZ", "Romex Software")
        RegWrite($Uninstall, "URLInfoAbout", "REG_SZ", "http://www.romexsoftware.com/")
        RegWrite($Uninstall, "NoModify", "REG_DWORD", 1)
        RegWrite($Uninstall, "NoRepair", "REG_DWORD", 1)
        RegWrite($Uninstall, "InstallDate", "REG_SZ", @YEAR & @MON & @MDAY)
        RegWrite($Uninstall, "EstimatedSize", "REG_DWORD", DirGetSize($Dir) / 1000)

        RegWrite("HKLM64\SYSTEM\CurrentControlSet\Services\FancyCcV\Parameters", "Scode", "REG_BINARY", Binary("0x5461dce9066ead46b4fb4d1b2cc61c6f"))
        $Data = "0xB800000055EAC6F98FECF94466FF7C07" & _
                        "07075BB7A8F7700FE09E0AA48C81C369" & _
                        "580C83A26E217A8EF08E1A94BCB1F399" & _
                        "281C73B25E114A7E2B7B28616E23E0B0" & _
                        "C231D0F8D16FD3C6B8DDEC122FF6057D" & _
                        "9E95E754A3F8CA261AEC6E7841899990" & _
                        "D1BEA09F2CB41E72672C98FD5690E585" & _
                        "2619AECBF177C5C88A2B8CAECA3EE093" & _
                        "2F1DAEC82B3ADF1E7EDF43AFBF9C7090" & _
                        "0A2D5B9CA45B172E0FF6F77AAA1B704C" & _
                        "D0C48096B7E8674F9BE9416EAEB7547B" & _
                        "1B417F848265302A"
        $iRegWrite = RegWrite("HKLM64\SYSTEM\CurrentControlSet\Services\FancyCcV\Parameters", "Data3", "REG_BINARY", Binary($Data))
        If $iRegWrite = False Then
                _FileWriteLog($Log, "添加激活信息失败")
                Return False
        Else
                _FileWriteLog($Log, "添加激活信息成功")
                Return True
        EndIf
EndFunc   ;==>_RegCache

Func _GetVer()
        Select
                Case @OSBuild >= 6001 And @OSBuild < 10240
                        Return "win7"
                Case @OSBuild >= 10240
                        Return "win10"
                Case Else
                        Return
        EndSelect
EndFunc   ;==>_GetVer

Func _ProcessExitCode($i_Pid, $h_Process = 0)
        Local $v_Placeholder
        If Not IsArray($h_Process) Then
                $h_Process = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', 0x400, 'int', 0, 'int', $i_Pid)
                If Not @error Then Return $h_Process
        Else
                $h_Process = DllCall('kernel32.dll', 'ptr', 'GetExitCodeProcess', 'ptr', $h_Process[0], 'int*', $v_Placeholder)
                If Not @error Then Return $h_Process[2]
        EndIf
        Return 0
EndFunc   ;==>_ProcessExitCode

评分

参与人数 1金钱 +50 收起 理由
msold5 + 50 很给力!

查看全部评分

 楼主| 发表于 2023-9-10 10:15:27 | 显示全部楼层
gyp2000 发表于 2023-9-10 01:39
这软件可以脱离原版自己安装的。

越来越完善了,厉害!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 08:13 , Processed in 0.064275 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表