Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nsy16 committed Feb 26, 2018
1 parent a527994 commit ff1907a
Showing 1 changed file with 67 additions and 61 deletions.
128 changes: 67 additions & 61 deletions silentbatchmaker-melba2.au3
Expand Up @@ -81,7 +81,7 @@ While True
GUICtrlSetData($lbFolder, $sDir)
$OPENDIR = $sDir ; update global value so next open will go to last opened folder
;$aFiles = _FileListToArrayRec($sDir, '*.msi;*.mst;*.exe', $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_RELPATH)
$aFiles = _FileListToArrayRec($sDir, '*.msi;*.exe', $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_RELPATH)
$aFiles = _FileListToArrayRec($sDir, '*.exe;*.msi;*.msp', $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_RELPATH)
If Not @error Then
_CreateControls()
For $i = 0 To UBound($pFname) - 1
Expand Down Expand Up @@ -243,61 +243,61 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
FileClose($File)


If UBound($aRow) - 1 < 2 Then ; only one entry
If UBound($aRow) - 1 < 2 Then ; only one entry - note need to check if multiple rows have empty reg completed entries


; Check registry - single file only
$msg = '@echo off&cls' & @CRLF
$msg &= 'for %%a in ("%~dp0\.") do set _parentdir=%%~nxa' & @CRLF
$msg &= 'title %_parentdir%' & @CRLF
$msg &= '' & @CRLF
$msg &= ':: Install ' & $parentDir & @CRLF
$msg &= ':: Generated by ' & $sTitle & @CRLF
$msg &= '' & @CRLF
For $i = 1 To UBound($aRow) - 1
$fPath = GUICtrlRead($aRow[$i][3])
$swtch = GUICtrlRead($aRow[$i][5])
$regKy = GUICtrlRead($aRow[$i][8])
$regDN = GUICtrlRead($aRow[$i][9])
$regDV = GUICtrlRead($aRow[$i][10])
;~ ; Check registry - single file only
;~ $msg = '@echo off&cls' & @CRLF
;~ $msg &= 'for %%a in ("%~dp0\.") do set _parentdir=%%~nxa' & @CRLF
;~ $msg &= 'title %_parentdir%' & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':: Install ' & $parentDir & @CRLF
;~ $msg &= ':: Generated by ' & $sTitle & @CRLF
;~ $msg &= '' & @CRLF
;~ For $i = 1 To UBound($aRow) - 1
;~ $fPath = GUICtrlRead($aRow[$i][3])
;~ $swtch = GUICtrlRead($aRow[$i][5])
;~ $regKy = GUICtrlRead($aRow[$i][8])
;~ $regDN = GUICtrlRead($aRow[$i][9])
;~ $regDV = GUICtrlRead($aRow[$i][10])

;ConsoleWrite("$regDN: " & $regDN & @CRLF)
;ConsoleWrite("$regDV: " & $regDV & @CRLF)
;~ ;ConsoleWrite("$regDN: " & $regDN & @CRLF)
;~ ;ConsoleWrite("$regDV: " & $regDV & @CRLF)

$msg &= 'set _fPath=%~dp0' & $fPath & @CRLF
$msg &= 'set _swtch=' & $swtch & @CRLF
$msg &= 'set _regKy=' & $regKy & @CRLF
;~ $msg &= 'set _fPath=%~dp0' & $fPath & @CRLF
;~ $msg &= 'set _swtch=' & $swtch & @CRLF
;~ $msg &= 'set _regKy=' & $regKy & @CRLF

Select
Case $regDV <> ""
$msg &= 'set _regDN=' & $regDN & @CRLF
$msg &= 'set _regDV=' & $regDV & @CRLF
$msg &= '' & @CRLF
$msg &= ':: query registry for DisplayVersion 64bit and 32bit uninstall locations' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
$msg &= '' & @CRLF
Case $regDN <> ""
$msg &= 'set _regDN=' & $regDN & @CRLF
$msg &= '' & @CRLF
$msg &= ':: query registry for DisplayName 64bit and 32bit uninstall locations' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :eof' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :eof' & @CRLF
$msg &= '' & @CRLF
EndSelect
;~ Select
;~ Case $regDV <> ""
;~ $msg &= 'set _regDN=' & $regDN & @CRLF
;~ $msg &= 'set _regDV=' & $regDV & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':: query registry for DisplayVersion 64bit and 32bit uninstall locations' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
;~ $msg &= '' & @CRLF
;~ Case $regDN <> ""
;~ $msg &= 'set _regDN=' & $regDN & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':: query registry for DisplayName 64bit and 32bit uninstall locations' & @CRLF
;~ $msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :end' & @CRLF
;~ $msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :end' & @CRLF
;~ $msg &= '' & @CRLF
;~ EndSelect

$msg &= ':: install software' & @CRLF
$msg &= 'echo Installing %_regDN%' & @CRLF
$msg &= 'start /wait "" "%_fPath%" %_swtch%' & @CRLF
$msg &= '' & @CRLF
$msg &= ':end' & @CRLF
Next
;~ $msg &= ':: install software' & @CRLF
;~ $msg &= 'echo Installing %_regDN%' & @CRLF
;~ $msg &= 'start /wait "" "%_fPath%" %_swtch%' & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':end' & @CRLF
;~ Next

;MsgBox(0, 'Debug', $msg)
;~ ;MsgBox(0, 'Debug', $msg)

Local $File = FileOpen($saveDir & '\install-batch-regcheck.cmd', 2) ;Use UTF8, overwrite existing data, create directory
FileWrite($File, $msg)
FileClose($File)
;~ Local $File = FileOpen($saveDir & '\install-batch-regcheck.cmd', 2) ;Use UTF8, overwrite existing data, create directory
;~ FileWrite($File, $msg)
;~ FileClose($File)



Expand All @@ -324,8 +324,8 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
$msg &= 'set _regDN=' & $regDN & @CRLF
$msg &= '' & @CRLF
$msg &= ':: query registry for DisplayName 64bit and 32bit uninstall locations' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :eof' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :eof' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :end' & @CRLF
$msg &= 'for /f "usebackq tokens=1-2*" %%a in (`reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayName" 2^>nul`) do if "%%c" equ "%_regDN%" goto :end' & @CRLF
$msg &= '' & @CRLF
$msg &= ':: install software' & @CRLF
$msg &= 'echo Installing %_regDN%' & @CRLF
Expand All @@ -338,8 +338,8 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
;~ $msg &= 'set _regDV=' & $regDV & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':: query registry for DisplayVersion 64bit and 32bit uninstall locations' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
;~ $msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
;~ $msg &= '' & @CRLF
;~ $msg &= ':: install software' & @CRLF
;~ $msg &= 'echo Installing ' & $parentDir & ' %_regDV%' & @CRLF
Expand All @@ -352,8 +352,8 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
$msg &= 'set _regDV=' & $regDV & @CRLF
$msg &= '' & @CRLF
$msg &= ':: query registry for DisplayVersion 64bit and 32bit uninstall locations' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :eof' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
$msg &= 'for /f "tokens=3" %%a in (''reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\%_regKy%" /v "DisplayVersion" 2^>nul'') do if "%%a" geq "%_regDV%" goto :end' & @CRLF
$msg &= '' & @CRLF
$msg &= ':: install software' & @CRLF
$msg &= 'echo Installing %_regDN% %_regDV%' & @CRLF
Expand Down Expand Up @@ -457,7 +457,7 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
$msg &= ' :: install software with switch' & @CRLF
$msg &= ' echo Installing %_regDN%' & @CRLF
EndIf
If $regDNCount = 0 Then
If $regDVCount > 0 And $regDNCount = 0 Then
$msg &= ' call set _regDV=%%_regDV_[%_index%]%%%' & @CRLF
$msg &= '' & @CRLF
$msg &= ' :: query registry for DisplayVersion 64bit and 32bit uninstall locations' & @CRLF
Expand All @@ -466,9 +466,7 @@ Func Save($saveDir) ; take all the exe files and switches and generate batch
$msg &= '' & @CRLF
$msg &= ' :: install software with switch' & @CRLF
$msg &= ' echo Installing %_regDN% %_regDV%' & @CRLF
EndIf

If $regDNCount > 0 And $regDNCount > 0 Then
ElseIf $regDVCount > 0 And $regDNCount > 0 Then
$msg &= ' call set _regDV=%%_regDV_[%_index%]%%%' & @CRLF
$msg &= '' & @CRLF
$msg &= ' :: multi query registry for 64bit and 32bit uninstall locations' & @CRLF
Expand Down Expand Up @@ -522,7 +520,7 @@ Func Load($profile)
;ConsoleWrite($line & @CRLF)

; read all values, in correct order
If StringInStr($line, "set _fPath") Then
If StringInStr($line, "set _fPath") or StringInStr($line, "set _exe") Then
; increment the counter if on this first section again
If $loop = "" Then ; Has not been past this section yet, set loop initial value
$loop = "initialised"
Expand All @@ -543,14 +541,17 @@ Func Load($profile)
$aLoadValues[$count][0] = $fPath
EndIf

If StringInStr($line, "set _swtch") Then
;ConsoleWrite($line & @CRLF)
;_ArrayDisplay($aLoadValues)

If StringInStr($line, "set _swtch") Or StringInStr($line, "set _switch") Then
$a = StringRegExpReplace($line, '(^.+?=)', "") ; Erase from beginning, to first "="
ConsoleWrite("_swtch: " & $a & @CRLF)
$swtch = $a
$aLoadValues[$count][1] = $swtch
EndIf

If StringInStr($line, "set _regKy") Then
If StringInStr($line, "set _regKy") Or StringInStr($line, "set _regK") Then
$a = StringRegExpReplace($line, '(^.+?=)', "") ; Erase from beginning, to first "="
ConsoleWrite("_regKy: " & $a & @CRLF)
$regKy = $a
Expand All @@ -573,6 +574,9 @@ Func Load($profile)
$regDV = $a
$aLoadValues[$count][4] = $regDV
EndIf

; NB - could exit loop here if all values loaded - eg look for :: and exitloop

EndIf

Wend
Expand Down Expand Up @@ -624,6 +628,7 @@ Func Test($rootdir, $path, $switch)
If FileExists($rootdir & "\" & $path) Then
If GetFileExtension($aFiles[$i]) == ".exe" Then Run($rootdir & '\' & $path & ' ' & $switch)
If GetFileExtension($aFiles[$i]) == ".msi" Then Run('msiexec /i "' & $rootdir & '\' & $path & '" ' & $switch)
If GetFileExtension($aFiles[$i]) == ".msp" Then Run('msiexec /update "' & $rootdir & '\' & $path & '" ' & $switch)
If GetFileExtension($aFiles[$i]) == ".mst" Then Run('msiexec /update "' & $rootdir & '\' & $path & '" ' & $switch)
Else
MsgBox(0, "Error locating file", "Cannot find file @ " & @CRLF & $rootdir & "\" & $path)
Expand Down Expand Up @@ -685,6 +690,7 @@ Func CreateRows(ByRef $aFiles)
$aRow[$i][5] = GUICtrlCreateCombo("", 527, $x, 107, 21)
If GetFileExtension($aFiles[$i]) == ".exe" Then GUICtrlSetData(-1, '/s|/S|/q|/s /v"/passive"|/s /v"/passive /norestart"|/S/v/qn /V"/qb"|/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-|/silent|/silent /accepteula|/sAll|-silent|-silent -eulaAccepted|/?', '/s')
If GetFileExtension($aFiles[$i]) == ".msi" Then GUICtrlSetData(-1, '/qb|/passive|/passive ALLUSERS=1|/?', '/passive')
If GetFileExtension($aFiles[$i]) == ".msp" Then GUICtrlSetData(-1, '/qb|/passive|/passive ALLUSERS=1|/?', '/passive')
If GetFileExtension($aFiles[$i]) == ".mst" Then GUICtrlSetData(-1, '/qb|/passive|/passive ALLUSERS=1|/?', '/passive')
; Right column
$aRow[$i][6] = GUICtrlCreateButton("Test", 634, $x, 55, 21)
Expand Down

0 comments on commit ff1907a

Please sign in to comment.