-
Notifications
You must be signed in to change notification settings - Fork 0
/
bl3.ps1
111 lines (87 loc) · 3.73 KB
/
bl3.ps1
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function Get-DirectoryPath {
param (
[string]$promptMessage = "Press enter if your Borderlands 3 folder is stored at C:\Program Files (x86)\Steam\steamapps\common\Borderlands 3, otherwise type in the path to BL3 and press enter",
[string]$defaultPath = "C:\Program Files (x86)\Steam\steamapps\common\Borderlands 3"
)
# Prompt the user for input
$userInput = Read-Host -Prompt $promptMessage
# If no input provided, use the default path
if ([string]::IsNullOrEmpty($userInput)) {
$userInput = $defaultPath
}
# Check if the directory path exists, otherwise keep prompting
while (-not (Test-Path -Path $userInput -PathType Container)) {
Write-Host "The directory does not exist. Please try again."
$userInput = Read-Host -Prompt $promptMessage
if ([string]::IsNullOrEmpty($userInput)) {
$userInput = $defaultPath
}
}
# Append \OakGame\Binaries to the path
$additionalDirectory = "OakGame\Binaries"
$selectedPath = Join-Path -Path $userInput -ChildPath $additionalDirectory
return $selectedPath
}
# Call the function to get the selected path
$selectedPath = Get-DirectoryPath
# Define the file URLs
$bl3Dx11InjectionUrl = "https://github.com/FromDarkHell/BL3DX11Injection/releases/download/v1.1.3/D3D11.zip"
$openHotfixLoaderUrl = "https://github.com/apple1417/OpenHotfixLoader/releases/download/v1.6/OpenHotfixLoader.zip"
# Define the file names to be removed
$fileNamesToRemove = @("a.zip", "b.zip")
# Define the file name to be removed from a different directory
$fileNameToRemove = "LICENSE"
# Function to download and extract files
function Download-AndExtractFile {
param (
[string]$url,
[string]$destinationPath
)
try {
# Download the file
$downloadedFile = Join-Path -Path $destinationPath -ChildPath (Split-Path -Leaf $url)
Invoke-WebRequest -Uri $url -OutFile $downloadedFile
# Extract the file
Expand-Archive -Path $downloadedFile -DestinationPath $destinationPath -Force
# Remove the downloaded zip file
Remove-Item $downloadedFile -Force
} catch {
Write-Host "Failed to download or extract file from $url"
}
}
# Download and extract bl3dx11injection
Download-AndExtractFile -url $bl3Dx11InjectionUrl -destinationPath $selectedPath\Win64
# Download and extract openhotfixloader
Download-AndExtractFile -url $openHotfixLoaderUrl -destinationPath (Join-Path -Path $selectedPath\Win64 -ChildPath "Plugins")
# Function to remove files in the selected path
function Remove-FilesInSelectedPath {
param (
[string]$selectedPath
)
foreach ($fileName in $fileNamesToRemove) {
$filePath = Join-Path -Path $selectedPath -ChildPath $fileName
if (Test-Path $filePath) {
Remove-Item $filePath -Force
Write-Host "Removed file: $filePath"
} else {
Write-Host "File not found: $filePath"
}
}
}
# Function to remove a file from a different directory within selected path
function Remove-FileFromDifferentDirectory {
param (
[string]$selectedPath
)
$filePath = Join-Path -Path (Join-Path -Path $selectedPath -ChildPath "Win64\Plugins") -ChildPath $fileNameToRemove
if (Test-Path $filePath) {
Remove-Item $filePath -Force
Write-Host "Removed file: $filePath"
} else {
Write-Host "File not found: $filePath"
}
}
# Call the function to remove files
Remove-FilesInSelectedPath -selectedPath $selectedPath
# Call the function to remove a file from a different directory
Remove-FileFromDifferentDirectory -selectedPath $selectedPath