# Function to run ConfigLayersAndVulkanDll ps script.
-# We define it as a macro so we can create an install and uninstall version.
# Return value is in $0 - 0 is success, all else is failure.
!macro ConfigLayersAndVulkanDLL un
Function ${un}ConfigLayersAndVulkanDLL
+
${If} ${RunningX64}
Strcpy $1 64
${Else}
Strcpy $1 32
${Endif}
+
+ # Create the script, the first two lines are the majorabi and ossize.
nsExec::ExecToStack 'cmd /k echo $$majorabi=${VERSION_ABI_MAJOR} >"$TEMP\VulkanRT\VulkanRT.ps1"'
nsExec::ExecToStack 'cmd /k echo $$ossize=$1 >>"$TEMP\VulkanRT\VulkanRT.ps1"'
nsExec::ExecToStack 'cmd /k type ConfigLayersAndVulkanDLL.ps1 >>"$TEMP\VulkanRT\VulkanRT.ps1"'
+
+ # Exectute the script by piping it to powershell.exe. This gets around possible OS
+ # security restrictions on running powershell scripts.
nsExec::ExecToStack 'cmd /k type "$TEMP\VulkanRT\VulkanRT.ps1" | powershell -NoProfile -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -Command -'
Rename "$TEMP\ConfigLayersAndVulkanDLL.log" "$TEMP\VulkanRT\ConfigLayersAndVulkanDLL1.${un}log"
pop $0
+
+ # If it failed, try again, with a full path to powershell.exe
${If} $0 != 0
nsExec::ExecToStack 'cmd /k type "$TEMP\VulkanRT\VulkanRT.ps1" | "$WINDIR\System32\WindowsPowerShell\v1.0\powershell" -NoProfile -NoLogo -NonInteractive -WindowStyle Hidden -inputformat none -Command -'
pop $0
Rename "$TEMP\ConfigLayersAndVulkanDLL.log" "$TEMP\VulkanRT\ConfigLayersAndVulkanDLL2.${un}log"
${Endif}
- ${If} $0 = 0
- # Read the return value of the script and put it in $0, stripping trailing newline
- FileOpen $1 "$TEMP\ConfigLayersAndVulkanDLL.stat" r
- FileRead $1 $2
- FileClose $1
- ${StrRep} $3 $2 "$\n" ""
- ${StrRep} $0 $3 "$\r" ""
- ${Endif}
+
+ # Read the return value of the script and put it in $0, stripping trailing newline
+ FileOpen $1 "$TEMP\ConfigLayersAndVulkanDLL.stat" r
+ FileRead $1 $2
+ FileClose $1
+ ${StrRep} $3 $2 "$\n" ""
+ ${StrRep} $0 $3 "$\r" ""
+
+ # Cleanup
Delete "$TEMP\ConfigLayersAndVulkanDLL.stat"
Delete "$TEMP\VulkanRT\VulkanRT.ps1"
+
FunctionEnd
!macroend
!insertmacro ConfigLayersAndVulkanDLL ""
# Function to run diagnostics if ConfigLayersAndVulkanDll ps script failed.
-# We define it as a macro so we can create an install and uninstall version.
# On entry $0, contains the return value from ConfigLayersAndVulkanDll.ps1. It shouldn't be changed.
!macro DiagConfigLayersAndVulkanDLL un
Function ${un}DiagConfigLayersAndVulkanDLL
${If} $0 != 0
SetOutPath "$INSTDIR"
Call DiagConfigLayersAndVulkanDLL
- SetErrors
- IntOp $1 10000 + $0
- ${Else}
- StrCpy $1 60
+ ClearErrors
+
+ # The Powershell script failed, and we don't know why.
+ # Simply configure system to use our loader and vulkaninfo.
+ MessageBox MB_OK "Warning!$\n$\nPowershell script called by VulkanRT Installer failed with error $0. Is Powershell installed on your system?$\n$\nWill configure system with Vulkan $FileVersion." /SD IDOK
+ ${If} ${RunningX64}
+ Delete $WINDIR\SysWow64\vulkan-${VERSION_ABI_MAJOR}.dll
+ Delete $WINDIR\SysWow64\vulkaninfo.exe
+ CopyFiles /SILENT $WINDIR\SysWow64\vulkan-$FileVersion.dll $WINDIR\SysWow64\vulkan-${VERSION_ABI_MAJOR}.dll
+ CopyFiles /SILENT $WINDIR\SysWow64\vulkaninfo-$FileVersion.exe $WINDIR\SysWow64\vulkaninfo.exe
+ ${Endif}
+ Delete $WINDIR\System32\vulkan-${VERSION_ABI_MAJOR}.dll
+ Delete $WINDIR\System32\vulkaninfo.exe
+ CopyFiles /SILENT $WINDIR\System32\vulkan-$FileVersion.dll $WINDIR\System32\vulkan-${VERSION_ABI_MAJOR}.dll
+ CopyFiles /SILENT $WINDIR\System32\vulkaninfo-$FileVersion.exe $WINDIR\System32\vulkaninfo.exe
+ ClearErrors
${Endif}
+ StrCpy $1 60
Call CheckForError
# We are done using ConfigLayersAndVulkanDLL.ps1, delete it. It will be re-installed
# vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry
# entries to use layers from the corresponding SDK
SetOutPath "$IDir"
- #ClearErrors
Call un.ConfigLayersAndVulkanDLL
${If} $0 != 0
SetOutPath "$IDir"
Call un.DiagConfigLayersAndVulkanDLL
- SetErrors
- IntOp $1 20000 + $0
+ MessageBox MB_OK "Warning!$\n$\nPowershell script called by VulkanRT Uninstaller failed with error $0. Is Powershell installed on your system?$\n$\nVulkan $FileVersion has been uninstalled from your system." /SD IDOK
+ ${If} ${RunningX64}
+ Delete $WINDIR\SysWow64\vulkan-${VERSION_ABI_MAJOR}.dll
+ Delete $WINDIR\SysWow64\vulkaninfo.exe
+ ${Endif}
+ Delete $WINDIR\System32\vulkan-${VERSION_ABI_MAJOR}.dll
+ Delete $WINDIR\System32\vulkaninfo.exe
+ ClearErrors
${Else}
StrCpy $1 85
${Endif}