Skip to content

Commit 70e88e8

Browse files
committed
make correktion for SteamVR Driver Installation to work correct unzipFile
1 parent 53c5588 commit 70e88e8

File tree

4 files changed

+124
-34
lines changed

4 files changed

+124
-34
lines changed

windows/web/dlmacro.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
!macro unzipFile name version local_file local_dir
6666

6767
DetailPrint "Unzipping ${name} ${version} to installation folder...."
68-
nsisunz::Unzip "${SLIMETEMP}\${local_file}" "${local_dir}"
68+
nsisunz::Unzip "${local_file}" "${local_dir}"
6969
Pop $0
7070
DetailPrint "Unzipping finished with $0."
7171

windows/web/slimevr_web_installer.nsi

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Unicode True
2323
!include .\steamdetect.nsh
2424
!include .\dlmacro.nsh
2525

26+
!define CSIDL_COMMON_DOCUMENTS 0x002E ; Define CSIDL_COMMON_DOCUMENTS if not already defined
27+
2628
!define SF_USELECTED 0
2729
!define MUI_ICON "run.ico"
2830
!define MUI_HEADERIMAGE
@@ -63,6 +65,7 @@ Unicode True
6365
!define SVRFeederDLFileZip "SlimeVR-Feeder-App-latest.zip"
6466

6567
Var JREneedInstall
68+
Var /GLOBAL PUBLIC
6669
Var /GLOBAL SteamVRResult
6770
Var /GLOBAL SteamVRLabelID
6871
Var /GLOBAL SteamVRLabelTxt
@@ -117,6 +120,13 @@ Function .onInit
117120
ReadRegStr $0 HKLM SOFTWARE\Valve\Steam InstallPath
118121
${EndIf}
119122
StrCpy $STEAMDIR $0
123+
124+
; Get "Public" user profile folder
125+
StrCpy $0 ""
126+
System::Call 'shell32::SHGetFolderPathW(i 0, i ${CSIDL_COMMON_DOCUMENTS}, i 0, i 0, t .r0)'
127+
${GetParent} $0 $0
128+
StrCpy $PUBLIC $0
129+
120130
FunctionEnd
121131

122132
!insertmacro ProcessCheck "un." "SteamVRResult"
@@ -439,7 +449,7 @@ Section "SlimeVR Server" SEC_SERVER
439449
SetOutPath $INSTDIR
440450

441451
!insertmacro dlFile "${SVRServerURLType}" "SlimeVR Server" "${SVRServerVersion}" "${SVRServerDLURL}" "${SVRServerDLFileZip}"
442-
!insertmacro unzipFile "SlimeVR Server" "${SVRServerVersion}" "${SLIMETEMP}\${SVRServerDLFileZip}" "SlimeVR"
452+
!insertmacro unzipFile "SlimeVR Server" "${SVRServerVersion}" "${SLIMETEMP}\${SVRServerDLFileZip}" "${SLIMETEMP}\SlimeVR"
443453

444454
${If} $SELECTED_INSTALLER_ACTION == "update"
445455
Delete "$INSTDIR\slimevr-ui.exe"
@@ -481,7 +491,7 @@ Section "Java JRE" SEC_JRE
481491
SectionIn RO
482492

483493
!insertmacro dlFile "${JREURLType}" "Java JRE" "${JREVersion}" "${JREDLURL}" "${JREDLFileZip}"
484-
!insertmacro unzipFile "Java JRE" "${JREVersion}" "${SLIMETEMP}\${JREDLFileZip}" "OpenJDK"
494+
!insertmacro unzipFile "Java JRE" "${JREVersion}" "${SLIMETEMP}\${JREDLFileZip}" "${SLIMETEMP}\OpenJDK"
485495

486496
# Make sure to delete all files on a update from jre, so if there is a new version no old files are left.
487497
IfFileExists "$INSTDIR\jre" 0 SEC_JRE_DIRNOTFOUND
@@ -504,13 +514,31 @@ Section "SteamVR Driver" SEC_VRDRIVER
504514
SetOutPath $INSTDIR
505515

506516
!insertmacro dlFile "${SVRDriverURLType}" "SteamVR Driver" "${SVRDriverVersion}" "${SVRDriverDLURL}" "${SVRDriverDLFileZip}"
507-
!insertmacro unzipFile "SteamVR Driver" "${SVRDriverVersion}" "${SLIMETEMP}\${SVRDriverDLFileZip}" "slimevr-openvr-driver-win64"
517+
!insertmacro unzipFile "SteamVR Driver" "${SVRDriverVersion}" "${SLIMETEMP}\${SVRDriverDLFileZip}" "${SLIMETEMP}\slimevr-openvr-driver-win64"
508518

509519
# Include SteamVR powershell script to register/unregister driver
510520
File "steamvr.ps1"
521+
File "steamcleanexternaldrivers.ps1"
511522

512-
DetailPrint "Copying SteamVR Driver to SteamVR..."
523+
DetailPrint "Removing old external drivers in SteamVR Config..."
513524
# If powershell is present - rely on automatic detection.
525+
526+
${DisableX64FSRedirection}
527+
CreateShortcut "$INSTDIR\steamcleanexternaldrivers.lnk" "$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" '-ExecutionPolicy Bypass -WindowStyle Hidden -File "$INSTDIR\steamcleanexternaldrivers.ps1"' "$INSTDIR\steamcleanexternaldrivers.ps1" 0
528+
Exec "explorer.exe $INSTDIR\steamcleanexternaldrivers.lnk"
529+
Sleep 5000
530+
${EnableX64FSRedirection}
531+
IfFileExists "$PUBLIC\Documents\SlimeVRUninstall_log.txt" 0 no_log
532+
FileOpen $1 "$PUBLIC\Documents\SlimeVRUninstall_log.txt" r
533+
FileRead $1 $2
534+
DetailPrint "$2"
535+
FileClose $1
536+
Delete "$PUBLIC\Documents\SlimeVRUninstall_log.txt"
537+
no_log:
538+
Delete "$INSTDIR\steamcleanexternaldrivers.lnk"
539+
Delete "$INSTDIR\steamcleanexternaldrivers.ps1"
540+
541+
DetailPrint "Copying SteamVR Driver to SteamVR..."
514542
${DisableX64FSRedirection}
515543
nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "$INSTDIR\steamvr.ps1" -SteamPath "$STEAMDIR" -DriverPath "${SLIMETEMP}\slimevr-openvr-driver-win64\slimevr"' $0
516544
${EnableX64FSRedirection}
@@ -530,7 +558,7 @@ Section "SlimeVR Feeder App" SEC_FEEDER_APP
530558

531559
!insertmacro dlFile "${SVRFeederURLType}" "SlimeVR Feeder App" "${SVRFeederVersion}" "${SVRFeederDLURL}" "${SVRFeederDLFileZip}"
532560
# The zip contains a folder named SlimeVR-Feeder-App-win64
533-
!insertmacro unzipFile "SlimeVR Feeder App" "${SVRFeederVersion}" "${SLIMETEMP}\${SVRFeederDLFileZip}" ""
561+
!insertmacro unzipFile "SlimeVR Feeder App" "${SVRFeederVersion}" "${SLIMETEMP}\${SVRFeederDLFileZip}" "${SLIMETEMP}"
534562

535563
DetailPrint "Copying SlimeVR Feeder App..."
536564
CopyFiles /SILENT "${SLIMETEMP}\SlimeVR-Feeder-App-win64\*" "$INSTDIR\Feeder-App"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[CmdletBinding(PositionalBinding=$false)]
2+
param (
3+
[parameter(Position=0)][string]$LogFile = "$env:Public\Documents\SlimeVRUninstall_log.txt"
4+
)
5+
6+
$ErrorActionPreference = 'Stop'
7+
8+
# Helper to log messages to $LogFile, ensuring directory exists
9+
function Log {
10+
param([string]$msg)
11+
$logDir = Split-Path -Path $LogFile -Parent
12+
if ($logDir -and -not (Test-Path -Path $logDir)) {
13+
try { New-Item -ItemType Directory -Path $logDir -Force | Out-Null } catch { }
14+
}
15+
Add-Content -Path $LogFile -Value ("{0}" -f $msg)
16+
}
17+
18+
# Required for System.Web.Script.Serialization.JavaScriptSerializer
19+
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
20+
21+
# Prune external SlimeVR driver(s)
22+
$OpenVrConfigPath = "$env:LOCALAPPDATA\openvr\openvrpaths.vrpath"
23+
if (Test-Path -Path $OpenVrConfigPath) {
24+
$OpenVrConfig = Get-Content -Path $OpenVrConfigPath -Encoding utf8 | Out-String | ConvertFrom-Json
25+
Log "Checking External Drivers in '$OpenVrConfigPath' for old SlimeVR Drivers..."
26+
$ExternalDriverPaths = @()
27+
if ($OpenVrConfig.external_drivers -and $OpenVrConfig.external_drivers.Length) {
28+
foreach ($ExternalDriverPath in $OpenVrConfig.external_drivers) {
29+
if (-not (Test-Path -Path "$ExternalDriverPath\driver.vrdrivermanifest")) {
30+
Log "VR driver path '$ExternalDriverPath' has no manifest."
31+
$ExternalDriverPaths += $ExternalDriverPath
32+
continue
33+
}
34+
$DriverManifest = Get-Content -Path "$ExternalDriverPath\driver.vrdrivermanifest" -Encoding utf8 | Out-String | ConvertFrom-Json
35+
if ($DriverManifest.name -eq "SlimeVR") {
36+
Log "Found external SlimeVR Driver in '$ExternalDriverPath'. Removing..."
37+
continue
38+
}
39+
$ExternalDriverPaths += $ExternalDriverPath
40+
}
41+
}
42+
if ($ExternalDriverPaths.Length -eq 0) {
43+
$OpenVrConfig.external_drivers = $null
44+
} else {
45+
$OpenVrConfig.external_drivers = $ExternalDriverPaths
46+
}
47+
[System.IO.File]::WriteAllLines($OpenVrConfigPath, (ConvertTo-Json -InputObject $OpenVrConfig -Compress))
48+
Log "Updated OpenVR config at '$OpenVrConfigPath'"
49+
} else {
50+
Log "OpenVR config not found at '$OpenVrConfigPath'. Skipping external driver prune."
51+
}

windows/web/steamvr.ps1

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,42 @@ $ErrorActionPreference = 'Stop'
1010
# Required for System.Web.Script.Serialization.JavaScriptSerializer
1111
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
1212

13-
# Prune external SlimeVR driver(s)
14-
$OpenVrConfigPath = "$env:LOCALAPPDATA\openvr\openvrpaths.vrpath"
15-
$OpenVrConfig = Get-Content -Path $OpenVrConfigPath -Encoding utf8 | Out-String | ConvertFrom-Json
16-
Write-Host "Checking `"$OpenVrConfigPath`" for SlimeVR Drivers..."
17-
$ExternalDriverPaths = @()
18-
if ($OpenVrConfig.external_drivers -and $OpenVrConfig.external_drivers.Length) {
19-
foreach ($ExternalDriverPath in $OpenVrConfig.external_drivers) {
20-
if (-not (Test-Path -Path "$ExternalDriverPath\driver.vrdrivermanifest")) {
21-
Write-Host "VR driver path `"$ExternalDriverPath`" has no manifest."
22-
$ExternalDriverPaths += $ExternalDriverPath
23-
continue
24-
}
25-
$DriverManifest = Get-Content -Path "$ExternalDriverPath\driver.vrdrivermanifest" -Encoding utf8 | Out-String | ConvertFrom-Json
26-
if ($DriverManifest.name -eq "SlimeVR") {
27-
Write-Host "Found external SlimeVR Driver in `"$ExternalDriverPath`". Removing..."
28-
continue
29-
}
30-
$ExternalDriverPaths += $ExternalDriverPath
31-
}
32-
}
33-
if ($ExternalDriverPaths.Length -eq 0) {
34-
$OpenVrConfig.external_drivers = $null
35-
} else {
36-
$OpenVrConfig.external_drivers = $ExternalDriverPaths
37-
}
38-
[System.IO.File]::WriteAllLines($OpenVrConfigPath, (ConvertTo-Json -InputObject $OpenVrConfig -Compress))
13+
# TODO: Remove the Prune external SlimeVR driver(s) part once its sure everything with
14+
# steamcleanexternaldrivers.ps1 is working fine without it.
15+
# This part was used to remove old SlimeVR drivers from the OpenVR config.
16+
# The Installation methode is not used for ~3 years now, so it should be safe to remove it.
17+
## Prune external SlimeVR driver(s)
18+
19+
#$OpenVrConfigPath = "$env:LOCALAPPDATA\openvr\openvrpaths.vrpath"
20+
## Check if the path exists to avoid errors. If the file does not exist we don't need to remove anything.
21+
#if (Test-Path -Path $OpenVrConfigPath) {
22+
# $OpenVrConfig = Get-Content -Path $OpenVrConfigPath -Encoding utf8 | Out-String | ConvertFrom-Json
23+
# Write-Host "Checking External Drivers in '$OpenVrConfigPath' for old SlimeVR Drivers..."
24+
# $ExternalDriverPaths = @()
25+
# if ($OpenVrConfig.external_drivers -and $OpenVrConfig.external_drivers.Length) {
26+
# foreach ($ExternalDriverPath in $OpenVrConfig.external_drivers) {
27+
# if (-not (Test-Path -Path "$ExternalDriverPath\driver.vrdrivermanifest")) {
28+
# Write-Host "VR driver path `"$ExternalDriverPath`" has no manifest."
29+
# $ExternalDriverPaths += $ExternalDriverPath
30+
# continue
31+
# }
32+
# $DriverManifest = Get-Content -Path "$ExternalDriverPath\driver.vrdrivermanifest" -Encoding utf8 | Out-String | ConvertFrom-Json
33+
# if ($DriverManifest.name -eq "SlimeVR") {
34+
# Write-Host "Found external SlimeVR Driver in `"$ExternalDriverPath`". Removing..."
35+
# continue
36+
# }
37+
# $ExternalDriverPaths += $ExternalDriverPath
38+
# }
39+
# }
40+
# if ($ExternalDriverPaths.Length -eq 0) {
41+
# $OpenVrConfig.external_drivers = $null
42+
# } else {
43+
# $OpenVrConfig.external_drivers = $ExternalDriverPaths
44+
# }
45+
# [System.IO.File]::WriteAllLines($OpenVrConfigPath, (ConvertTo-Json -InputObject $OpenVrConfig -Compress))
46+
#} else {
47+
# Write-Host "OpenVR config not found at `"$OpenVrConfigPath`". Skipping external driver prune."
48+
#}
3949

4050
# Remove trackers on uninstall
4151
if ($Uninstall -eq $true) {
@@ -89,9 +99,10 @@ foreach ($SteamVrPath in $SteamVrPaths) {
8999
exit 0
90100
}
91101
try {
92-
Copy-Item -Recurse -Force -Path $DriverPath -Destination "$SteamVrPath\drivers"
102+
Copy-Item -Recurse -Force -Path $DriverPath -Destination "$SteamVrPath\drivers\"
93103
} catch [System.Management.Automation.ActionPreferenceStopException] {
94-
Write-Host "Failed to remove old SlimeVR driver. Make sure SteamVR is closed and there's enough free disk space."
104+
Write-Host "Failed to copy new SlimeVR driver. Error: $_"
105+
Write-Host "Make sure SteamVR is closed and there's enough free disk space."
95106
exit 1
96107
}
97108
Write-Host "Installed SlimeVR Driver to `"$SteamVrDriverPath`""

0 commit comments

Comments
 (0)