1' 2' ScummVM - Graphic Adventure Engine 3' 4' ScummVM is the legal property of its developers, whose names 5' are too numerous to list here. Please refer to the COPYRIGHT 6' file distributed with this source distribution. 7' 8' This program is free software; you can redistribute it and/or 9' modify it under the terms of the GNU General Public License 10' as published by the Free Software Foundation, version 2 11' of the License. 12' 13' This program is distributed in the hope that it will be useful, 14' but WITHOUT ANY WARRANTY; without even the implied warranty of 15' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16' GNU General Public License for more details. 17' 18' You should have received a copy of the GNU General Public License 19' along with this program; if not, write to the Free Software 20' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21' 22'/ 23 24'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 25' This script calls the iscc tool to generate a Inno Setup Windows installer for ScummVM 26' 27' It tries to read the Inno Setup installation folder from the registry and then calls the 28' command line script compiler to create the installer. 29' 30' This is called from the postbuild.cmd batch file 31'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 32 33'================================================================ 34' TODO: Reduce duplication with revision.vbs script 35' (ReadRegistryKey and ParseCommandLine are identical) 36'================================================================ 37 38Option Explicit 39 40Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject") 41Dim WshShell : Set WshShell = CreateObject("WScript.Shell") 42 43' Folders 44Dim rootFolder : rootFolder = "" 45Dim targetFolder : targetFolder = "" 46 47' Parse our command line arguments 48If ParseCommandLine() Then 49 CreateInstaller() 50End If 51 52'//////////////////////////////////////////////////////////////// 53'// Installer creation 54'//////////////////////////////////////////////////////////////// 55Sub CreateInstaller() 56 ' Get inno installation folder 57 Dim innoPath : innoPath = GetInnoPath() 58 If (innoPath = "") Then 59 Exit Sub 60 End If 61 62 ' Build command line 63 Dim commandLine : commandLine = """" & innoPath & "\iscc.exe"" /Qp" & _ 64 " /O""" & targetFolder & """" & _ 65 " """ & rootFolder & "\dists\win32\scummvm.iss""" 66 67 Dim oExec: Set oExec = WshShell.Exec(commandline) 68 If Err.Number <> 0 Then 69 Wscript.StdErr.WriteLine "Error running iscc.exe!" 70 Exit Sub 71 End If 72 73 ' Wait till the application is finished ... 74 Dim ostdOut : Set oStdOut = oExec.StdOut 75 Do While oExec.Status = 0 76 If Not ostdOut.AtEndOfStream Then 77 Wscript.StdErr.WriteLine ostdOut.ReadAll 78 End If 79 80 WScript.Sleep 100 81 Loop 82 83 If oExec.ExitCode <> 0 Then 84 Wscript.StdErr.WriteLine "Error while creating installer!" 85 Exit Sub 86 End If 87End Sub 88 89Function GetInnoPath() 90 ' Get the directory where Inno Setup (should) reside(s) 91 Dim sInno 92 93 ' First, try with 32-bit architecture 94 sInno = ReadRegistryKey("HKLM", "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1", "InstallLocation", 32) 95 96 If sInno = "" Or IsNull(sInno) Then 97 ' No 32-bit version of Inno Setup installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored) 98 sInno = ReadRegistryKey("HKLM", "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1", "InstallLocation", 64) 99 End If 100 101 ' Check if Inno Setup is present 102 If sInno = "" Then 103 Wscript.StdErr.WriteLine "Inno Setup not installed!" 104 Exit Function 105 End If 106 107 GetInnoPath = sInno 108End Function 109 110'//////////////////////////////////////////////////////////////// 111'// Utilities 112'//////////////////////////////////////////////////////////////// 113Function ParseCommandLine() 114 ParseCommandLine = True 115 116 If Wscript.Arguments.Count <> 2 Then 117 Wscript.StdErr.WriteLine "[Error] Invalid number of arguments (was: " & Wscript.Arguments.Count & ", expected: 2)" 118 119 ParseCommandLine = False 120 Exit Function 121 End If 122 123 ' Get our arguments 124 rootFolder = Wscript.Arguments.Item(0) 125 targetFolder = Wscript.Arguments.Item(1) 126 127 ' Check that the folders are valid 128 If Not FSO.FolderExists(rootFolder) Then 129 Wscript.StdErr.WriteLine "[Error] Invalid root folder (" & rootFolder & ")" 130 131 ParseCommandLine = False 132 Exit Function 133 End If 134 135 If Not FSO.FolderExists(targetFolder) Then 136 Wscript.StdErr.WriteLine "[Error] Invalid target folder (" & targetFolder & ")" 137 138 ParseCommandLine = False 139 Exit Function 140 End If 141 142 ' Set absolute paths 143 rootFolder = FSO.GetAbsolutePathName(rootFolder) 144 targetFolder = FSO.GetAbsolutePathName(targetFolder) 145End Function 146 147Function ReadRegistryKey(shive, subkey, valuename, architecture) 148 Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams 149 150 ' First, get the Registry Provider for the requested architecture 151 Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet") 152 objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32 153 Set objLocator = CreateObject("Wbemscripting.SWbemLocator") 154 Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) 155 Set objReg = objServices.Get("StdRegProv") 156 157 ' Check the hive and give it the right value 158 Select Case shive 159 Case "HKCR", "HKEY_CLASSES_ROOT" 160 hiveKey = &h80000000 161 Case "HKCU", "HKEY_CURRENT_USER" 162 hiveKey = &H80000001 163 Case "HKLM", "HKEY_LOCAL_MACHINE" 164 hiveKey = &h80000002 165 Case "HKU", "HKEY_USERS" 166 hiveKey = &h80000003 167 Case "HKCC", "HKEY_CURRENT_CONFIG" 168 hiveKey = &h80000005 169 Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98 170 hiveKey = &h80000006 171 Case Else 172 MsgBox "Hive not valid (ReadRegistryKey)" 173 End Select 174 175 Set Inparams = objReg.Methods_("GetStringValue").Inparameters 176 Inparams.Hdefkey = hiveKey 177 Inparams.Ssubkeyname = subkey 178 Inparams.Svaluename = valuename 179 Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx) 180 181 ReadRegistryKey = Outparams.SValue 182End Function 183