-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added essential Windows update to installer
- Loading branch information
Showing
7 changed files
with
1,044 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
; | ||
; Download and install KB hotfix (if not already installed) | ||
; | ||
|
||
;---------------------------------------- | ||
; In: ID = KB number | ||
; URL = Download URL | ||
; TEMPFILE = Temp filename to use | ||
;---------------------------------------- | ||
!macro __InstallKB ID URL TEMPFILE | ||
Push $0 | ||
${IsKBInstalled} ${ID} $0 | ||
${If} $0 == 0 | ||
DetailPrint "Installing ${ID} ..." | ||
NSISdl::download ${URL} ${TEMPFILE} | ||
Pop $0 | ||
${If} $0 != "success" | ||
DetailPrint "* Download of ${ID} failed:" | ||
DetailPrint "* $0" | ||
DetailPrint "* Installation continuing anyway" | ||
${Else} | ||
${ExecInstallKB} ${ID} ${TEMPFILE} | ||
${IsKBInstalled} ${ID} $0 | ||
${If} $0 == 0 | ||
DetailPrint "* Some error occured installing ${ID}" | ||
DetailPrint "* It is required in order to run Multi Theft Auto : San Andreas" | ||
DetailPrint "* Installation continuing anyway" | ||
${EndIf} | ||
${EndIf} | ||
${EndIf} | ||
Pop $0 | ||
!macroend | ||
!macro _InstallKB ID URL | ||
!insertmacro __InstallKB ${ID} ${URL} "$TEMP\${ID}.msu" | ||
!macroend | ||
!define InstallKB `!insertmacro _InstallKB` | ||
|
||
|
||
;---------------------------------------- | ||
; Run KB installer | ||
; In: ID = KB number | ||
; FILENAME = KB file | ||
;---------------------------------------- | ||
!macro _ExecInstallKB ID FILENAME | ||
Push $0 | ||
Push $1 | ||
Push $R1 | ||
StrCpy $1 "$TEMP\RunMSU.bat" | ||
FileOpen $0 $1 w | ||
FileWrite $0 "@echo off$\r$\n" | ||
FileWrite $0 "start $\"$\" wusa /quiet /norestart $\"${FILENAME}$\"" | ||
FileClose $0 | ||
ExecWait $1 | ||
|
||
; Wait for wusa.exe to start | ||
${ProcessWait} wusa.exe 5000 $0 | ||
|
||
; Wait for slui.exe (license warning) to start and terminate it | ||
${ProcessWait} slui.exe 4000 $0 | ||
${TerminateProcess} slui.exe $0 | ||
Sleep 500 | ||
${TerminateProcess} slui.exe $0 | ||
|
||
; Show progress while wusa.exe is running | ||
DetailPrint "" | ||
StrCpy $R1 0 | ||
${Do} | ||
IntOp $R1 $R1 + 1 | ||
IntOp $0 $R1 & 0x0f | ||
${If} $0 == 1 | ||
${DetailUpdate} "Please wait..." | ||
DetailPrint "Working..." | ||
${EndIf} | ||
${ProcessWaitClose} wusa.exe 1000 $0 | ||
${If} $0 > 0 | ||
StrCpy $R1 100 | ||
${EndIf} | ||
${DetailUpdate} "Installing ${ID}: $R1% done..." | ||
${LoopUntil} $0 > 0 | ||
Pop $R1 | ||
Pop $1 | ||
Pop $0 | ||
!macroend | ||
!define ExecInstallKB `!insertmacro _ExecInstallKB` | ||
|
||
|
||
;---------------------------------------- | ||
; Determine if a KB hotfix is already installed | ||
; In: ID = KB number | ||
; Out: RESULT = (0 - no, 1 - yes) | ||
;---------------------------------------- | ||
!macro _IsKBInstalled ID RESULT | ||
nsExec::ExecToStack 'cmd /Q /C "wmic qfe get hotfixid | findstr "^${ID}""' | ||
Pop ${RESULT} ; return value (it always 0 even if an error occured) | ||
Pop ${RESULT} ; command output | ||
${If} ${RESULT} == "" | ||
StrCpy ${RESULT} 0 | ||
${Else} | ||
StrCpy ${RESULT} 1 | ||
${EndIf} | ||
!macroend | ||
!define IsKBInstalled `!insertmacro _IsKBInstalled` | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
!include LogicLib.nsh | ||
|
||
!macro GetTextExtent String Width # Seems to be accurate and return big values | ||
System::Alloc 16 | ||
Pop $0 | ||
System::Call "*$0(i 0, i 0, i 0, i 0)" | ||
|
||
System::Call "User32::GetDC(i $9) i .r1" | ||
System::Call "User32::DrawText(i r1, t '${String}', i -1, i r0, i 1024) i .r1" | ||
|
||
System::Call "*$0(i .r1,i .r2,i .r3,i .r4)" | ||
|
||
StrCpy ${Width} $3 | ||
# StrCpy ${Height} $4 #$4 is Height if need be in future | ||
|
||
System::Free $0 | ||
!macroend | ||
|
||
!macro Max Num1 Num2 | ||
${If} ${Num1} > ${Num2} | ||
StrCpy ${Num2} ${Num1} | ||
${Else} | ||
StrCpy ${Num1} ${Num2} | ||
${EndIf} | ||
!macroend | ||
|
||
|
||
;---------------------------------------- | ||
; In: FILENAME = filename | ||
; Out: MAJOR.MINOR.RELEASE.BUILD | ||
;---------------------------------------- | ||
!macro _GetDLLVersionNumbers FILENAME MAJOR MINOR RELEASE BUILD | ||
Push $R8 | ||
Push $R9 | ||
GetDLLVersion "${FILENAME}" $R8 $R9 | ||
IntOp ${MAJOR} $R8 / 0x00010000 | ||
IntOp ${MINOR} $R8 & 0x0000FFFF | ||
IntOp ${RELEASE} $R9 / 0x00010000 | ||
IntOp ${BUILD} $R9 & 0x0000FFFF | ||
Pop $R9 | ||
Pop $R8 | ||
!macroend | ||
!define GetDLLVersionNumbers `!insertmacro _GetDLLVersionNumbers` | ||
|
||
|
||
;---------------------------------------- | ||
; Overwrite last DetailPrint line | ||
; From http://nsis.sourceforge.net/DetailUpdate | ||
;---------------------------------------- | ||
Function DetailUpdate | ||
Exch $R0 | ||
Push $R1 | ||
Push $R2 | ||
Push $R3 | ||
|
||
FindWindow $R2 `#32770` `` $HWNDPARENT | ||
GetDlgItem $R1 $R2 1006 | ||
SendMessage $R1 ${WM_SETTEXT} 0 `STR:$R0` | ||
GetDlgItem $R1 $R2 1016 | ||
|
||
System::Call *(&t${NSIS_MAX_STRLEN}R0)i.R2 | ||
System::Call *(i0,i0,i0,i0,i0,iR2,i${NSIS_MAX_STRLEN},i0,i0)i.R3 | ||
|
||
!define LVM_GETITEMCOUNT 0x1004 | ||
!define LVM_SETITEMTEXTW 0x1074 | ||
SendMessage $R1 ${LVM_GETITEMCOUNT} 0 0 $R0 | ||
IntOp $R0 $R0 - 1 | ||
System::Call user32::SendMessage(iR1,i${LVM_SETITEMTEXTW},iR0,iR3) | ||
|
||
System::Free $R3 | ||
System::Free $R2 | ||
|
||
Pop $R3 | ||
Pop $R2 | ||
Pop $R1 | ||
Pop $R0 | ||
FunctionEnd | ||
!macro DetailUpdate Text | ||
Push `${Text}` | ||
Call DetailUpdate | ||
!macroend | ||
!define DetailUpdate `!insertmacro DetailUpdate` |
Oops, something went wrong.