-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyToGameFolder.ps1
More file actions
62 lines (52 loc) · 2.03 KB
/
Copy pathCopyToGameFolder.ps1
File metadata and controls
62 lines (52 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!powershell.exe -ExecutionPolicy Bypass -File
param(
[String]$Configuration="Debug"
)
. ./BuildInfo.ps1
function Find-GameInstallPath {
$gameFolder = $null
# Try Steam first
try {
$steamDir = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam" -Name "InstallPath" -ErrorAction Stop | Select-Object -ExpandProperty InstallPath
$steamGamePath = Join-Path $steamDir "steamapps/common/BlackMythWukong"
if (Test-Path $steamGamePath) {
Write-Host "Discovered game in Steam: $steamGamePath"
return $steamGamePath
}
} catch {
# Steam registry key not found, continue to Epic
}
# Try Epic Games via manifest files
$epicManifestFolder = "C:\ProgramData\Epic\EpicGamesLauncher\Data\Manifests"
if (Test-Path $epicManifestFolder) {
$manifestFiles = Get-ChildItem -Path $epicManifestFolder -Filter "*.item"
foreach ($manifestFile in $manifestFiles) {
try {
$manifest = Get-Content $manifestFile.FullName | ConvertFrom-Json
if ($manifest.AppName -eq "f53c5471fd0e47619e72b6d21a527abe") {
$epicPath = $manifest.InstallLocation
if (Test-Path $epicPath) {
Write-Host "Discovered game in Epic Games: $epicPath"
return $epicPath
}
}
} catch {
# Skip invalid manifest files
}
}
}
# Not found
Write-Error "Could not find BlackMythWukong installation in Steam or Epic Games directories."
Exit 1
}
$gamePath = Find-GameInstallPath
$destRoot = Join-Path $gamePath "b1"
$coopBase = "$env:APPDATA/ReadyM.Launcher/WukongMP"
# Perform copies
foreach ($item in $allFiles) {
$files = $item[0]
$sourceDir = $item[1]
# Chain the replace operations. The output of the first becomes the input for the second.
$destDir = $item[2] -replace '@GAME', $destRoot -replace '@APPDATA', $coopBase
CopyFiles $files $sourceDir $destDir
}