-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSE-Downloader.ps1
More file actions
604 lines (563 loc) · 28.1 KB
/
SE-Downloader.ps1
File metadata and controls
604 lines (563 loc) · 28.1 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<#
Silverlock Script Extender Downloader
The Silverlock Team builds script extensions for Bethesda games, expanding the modding capability said games.
Currently supports:
Fallout 3 (FOSE)
Fallout: New Vegas (NVSE)
Fallout 4 (F4SE)
Supports Fallout: London and the version rollback
Fallout 76 (only the SFE tool for Text Chat and Perk Loader mods) (F76SFE)
Skyrim Special/Anniversary Edition (SKSE64)
GOG version needs validation
Skyrim Original Edition (No Longer Updated!) (SKSE)
Skyrim VR (SKSEVR)
Oblivion (OBSE)
Oblivion Remastered (OBSE64)
Morrowind (MWSE)
Starfield (SFSE)
Nexusmods API Reference: https://app.swaggerhub.com/apis-docs/NexusMods/nexus-mods_public_api_params_in_form_data/1.0#/
Nexusmods API AUP: https://help.nexusmods.com/article/114-api-acceptable-use-policy
Checks matching Silverlock SE page for latest file version against locally installed
Updates if available
Runs if flag set
Parameters:
-SEGame <designation> (four character game designation on silverlock.org)
-RunGame <true/false> (string, default false)
-dlkeep <true/false> (string, default false)
-hardpath (string, file path to game folder)
-nexusAPI (string, generated from https://www.nexusmods.com/users/myaccount?tab=api)
Usage:
se-downloader.ps1 -SEGame F4SE -RunGame true
Checks game for Fallout 4 Script Extender, and launches the game when completed
se-downloader.ps1 -SEGame FOSE -hardpath "G:\FO3GOTY"
Checks game for Fallout 3 with a direct install path
se-downloader.ps1 -SEGame SKSE64
Checks game for Skyrim Special Edition Script Extender
se-downloader.ps1 -SEGame F76SFE -dlkeep true -nexusAPI "NexusMods API Key"
Checks game for Fallout 76 SFE, an overlay DLL for Text Chat, requires NexusMods API Key, and does not delete the extracted download
#>
Param (
[Parameter(Mandatory = $true)]
[ValidateSet("FOSE", "NVSE", "F4SE", "F76SFE", "OBSE", "OBSE64", "SKSE", "SKSE64", "SKSEVR", "MWSE", "SFSE")]
[string]$SEGame,
[Parameter()]
[ValidateSet("true", "false")]
[string]$RunGame = "false",
[Parameter()]
[ValidateSet("true", "false")]
[string]$dlkeep = "false",
[Parameter()]
[ValidateSet("true", "false")]
[string]$forceDL = "false",
[Parameter()]
[string]$hardpath,
[Parameter()]
[string]$nexusAPI = (Get-Content "..\nexus.api") # NexusMods API Key (https://www.nexusmods.com/users/myaccount?tab=api)
)
# Convert string to boolean
$RunGame = [System.Convert]::ToBoolean($RunGame)
$dlkeep = [System.Convert]::ToBoolean($dlkeep)
$forceDL = [System.Convert]::ToBoolean($forceDL)
$global:SEGame = $SEGame
Function Get-GamePath {
# Get the Install Path from the uninstall registry
If (($hardpath.Length -gt 4) -and (Test-path $hardpath)) {
Write-Log -Level Debug -Message "Hard Path provided: $($hardpath)"
$global:gamepath = $hardpath
} Else {
Try {
$global:gamepath = get-childitem -recurse HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | get-itemproperty | Where-Object { $_ -match $GameName } | Select-object -first 1 -expandproperty InstallLocation
Test-path $gamepath
Write-Log -Level Debug -Message "SEGame $SEGame path found in registry: $($gamepath)"
} Catch {
Write-Log -Level Error -Message "Unable to find installation directory for $GameName"
Exit 1
}
}
$global:gog = ($gamepath -notmatch "steamapps") # Identify if not using Steam for the install path, assume its GOG, as the Epic Store install is officially unsupported
# Oblivion Remastered has a deeper path to the real executable folder
If ($SEGame -eq "OBSE64") {
$global:gamepath = "$gamepath\OblivionRemastered\Binaries\Win64"
}
}
Function Get-NexusMods {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias("modID")]
[string]$nexusmodID,
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias("gameID")]
[string]$nexusgameID,
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]$nexusfileindex
)
If (!($gamepath)) { Get-GamePath }
Write-Log -Level Debug -Message "Get-NexusMods called with gameID: $($nexusgameID), modID: $($nexusmodID), fileindex: $($nexusfileindex)"
If ($nexusAPI -eq "") { Write-Log -Level Error -Message "Nexus API Key is empty"; Exit 1 }
$nexusHeaders = @{
"Accept" = "application/json"
"apikey" = "$nexusAPI"
}
$global:url = "https://api.nexusmods.com"
Try {
$global:WebResponse = (Invoke-WebRequest "https://api.nexusmods.com/v1/games/$nexusgameID/mods/$nexusmodID/files.json" -Headers $nexusHeaders -UseBasicParsing).Content | ConvertFrom-Json | Select-Object -Property @{ L = 'files'; E = { $_.files[$nexusfileindex] } }
$global:json = $WebResponse.files
$global:latestfileid = $json.file_id[0]
$global:dlResponse = (Invoke-WebRequest "https://api.nexusmods.com/v1/games/$nexusgameID/mods/$nexusmodID/files/$latestfileid/download_link.json" -Headers $nexusHeaders).Content | ConvertFrom-Json | Where-Object { $_.short_name -eq "Nexus CDN" }
# if Select-Object returns an error, set the $halt flag
If ($null -eq $dlResponse) {
Write-Log -Level Error -Message "Unable to access NexusMods API"
Write-Log -Level Error -Message "$($Error[0].Exception.Message)"
Write-Log -Level Error -Message "API Key: $nexusAPI"
Write-Log -Level Error -Message "Game: $GameName"
Write-Log -Level Error -Message "Mod ID: $nexusmodID"
$global:halt = $true
# throw error
Throw "Unable to access NexusMods API"
}
If ($SEGame -eq "FOSE") {
# FOSE in a post-GFWL has a tag of -newloader, need to trim that off to work properly.
$global:dl = [PSCustomObject]@{
ver = [System.Version]::Parse("0.$(($json.version).Replace('-newloader', ''))")
url = $dlResponse[0].URI
file = $json.file_name
}
} Else {
$global:dl = [PSCustomObject]@{
ver = [System.Version]::Parse("0.$($json.version)")
url = $dlResponse[0].URI
file = $json.file_name
nexusver = $json.version
}
}
$global:subfolder = ($dl.file).Replace('.7z', '') # f4se_0_06_20
Write-Log -Level Debug -Message "NexusMods API returned: $($dl.file), version $($dl.ver) for $($SEGame)"
Write-Log -Level Debug -Message "NexusMods API returned: $($dl.url)"
} Catch {
Write-Log -Level Error -Message "Unable to access NexusMods API"
Write-Log -Level Error -Message "$($Error[0].Exception.Message)"
Write-Log -Level Error -Message "API Key: $nexusAPI"
Write-Log -Level Error -Message "Game: $GameName"
Write-Log -Level Error -Message "Mod ID: $nexusmodID"
$global:halt = $true
}
}
Function Get-GitHubMod {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]$url
)
If (!($gamepath)) { Get-GamePath }
Write-Log -Level Debug -Message "Get-GitHubMod called with URL: $($url)"
Try {
$WebResponse = Invoke-WebRequest $url -Headers @{ "Accept" = "application/json" } -UseBasicParsing
$json = $WebResponse.Content | ConvertFrom-Json
$json = $json[0]
If ($SEGame -eq "SKSE64") {
# SKSE64 has a GOG version, need to check for that
$global:dl = [PSCustomObject]@{
ver = [System.Version]::Parse("0." + ($json.tag_name).Replace("v", "")) # 0. + 5.1.6 = 0.5.1.6
url = If ($gog) { $json.assets.browser_download_url | Where-Object { $_ -match "gog" } } Else { $json.assets.browser_download_url | Where-Object { $_ -notmatch "gog" } } # https://github.com/xNVSE/NVSE/releases/download/5.1.6/nvse_5_1_beta6.7z
file = If ($gog) { $json.assets.name | Where-Object { $_ -match "gog" } } Else { $json.assets.name | Where-Object { $_ -notmatch "gog" } } # nvse_5_1_beta6.7z
}
} Else {
$global:dl = [PSCustomObject]@{
ver = [System.Version]::Parse("0." + ($json.tag_name).Replace("v", "")) # 0. + 5.1.6 = 0.5.1.6
url = If ($gog) { $json.assets.browser_download_url | Where-Object { $_ -match "gog" } } Else { $json.assets.browser_download_url | Where-Object { $_ -notmatch "gog" } } # https://github.com/xNVSE/NVSE/releases/download/5.1.6/nvse_5_1_beta6.7z
file = If ($gog) { $json.assets.name | Where-Object { $_ -match "gog" } } Else { $json.assets.name | Where-Object { $_ -notmatch "gog" } } # nvse_5_1_beta6.7z
}
}
$subfolder = ($dl.file).Replace('.7z', '') # f4se_0_06_20
Write-Log -Level Debug -Message "GitHub API returned: $($dl.file), version $($dl.ver) for $($SEGame)"
Write-Log -Level Debug -Message "GitHub API returned: $($dl.url)"
} Catch {
Write-Log -Level Error -Message "Unable to access URL: $url"
Write-Log -Level Error -Message "$($Error[0].Exception.Message)"
Write-Log -Level Error -Message "Game: $GameName"
$global:halt = $true
}
}
Function Get-CurrentVersion {
# Get current install version
Try {
If ($null -eq $global:currentSE) {
$global:currentSE = Get-Item "$gamepath\$($SEGame.ToLower())_*.dll" -Exclude "$($SEGame)_steam_loader.dll", "$($SEGame.ToLower())_editor*.dll" # f4se_1_10_163.dll
$global:currentSE = (Get-Item $global:currentSE).VersionInfo.FileVersion # 0, 0, 6, 20
If ($global:currentSE -is [System.Array]) { $global:currentSE = $global:currentSE[0] }
$global:currentSE = $global:currentSE.Replace(', ', '.') # 0.0.6.20
$global:currentSE = [System.Version]::Parse($global:currentSE)
} ElseIf ($SEGame -eq "F76SFE") {
$global:currentSE = (Get-Item "$gamepath\dxgi.dll").VersionInfo.FileVersion # 0, 0, 6, 20
If ($global:currentSE -is [System.Array]) { $global:currentSE = $global:currentSE[0] }
$global:currentSE = [System.Version]::Parse($global:currentSE.Replace(', ', '.'))
}
Write-Log -Level Debug -Message "Current version of $($SEGame) found: $($global:currentSE)"
} Catch {
$global:currentSE = [System.Version]::Parse("0.0.0.0") # Means you don't have it
Write-Log -Level Error -Message "Unable to find current version of $($SEGame), defaulting version compare to $($global:currentSE)"
}
}
Function Get-Download {
[CmdletBinding()]
Param (
[Parameter()]
[string]$downloadURL,
[Parameter()]
[string]$downloadFile = "$($dl.file)",
[Parameter()]
[string]$saveDir = "$env:USERPROFILE\Downloads",
[Parameter()]
[string]$extractPath
)
# Check for 7Zip4Powershell module, install if not found, and import it
If (!(Get-Module -Name "7Zip4Powershell")) {
Write-Log -Level Debug -Message "7Zip4Powershell module not found, installing..."
Install-Module -Name 7Zip4Powershell -Scope CurrentUser -Confirm:$false -Force
}
Import-Module -Name 7Zip4Powershell
Write-Log -Message "Downloading Source version ($($dl.url))" -Level Info
Invoke-WebRequest $downloadURL -OutFile "$saveDir\$downloadFile" -UseBasicParsing
If ($forceDL) {
# Cleanup Fallout 4 directory of older F4SE components
#Write-Log -Message "Cleaning up older Local $($SEGame) files" -Level Info
#Get-ChildItem -Path "$gamepath\$($SEGame)*" -Exclude "$SEGame-Updater.log" | Remove-Item -Force -Recurse
}
# Extract F4SE to the Fallout 4 folder (f4path\f4se_x_xx_xx)
# If $useSubfolder is true, then we need to extract to a subfolder instead of directly into the root game folder
If ($global:useSubfolder) {
$subfolder = $SEGame.ToLower()
$extractPath = "$gamepath\$($subfolder)"
}
Write-Log -Message "Extracting Source $($SEGame) files $downloadFile to $($extractPath))" -Level Info
Expand-7zip -ArchiveFileName "$saveDir\$downloadFile" -TargetPath $extractPath
Write-Log -Message "Copying Source $($SEGame) files to game path" -Level Info
Copy-Item "$extractPath\*" -include *.dll, *.exe -Destination $gamepath -Recurse -Force
# Cleanup
If ($dlkeep -eq $false) {
#Write-Log -Message "Cleaning up extracted files from $($extractPath)" -Level Info
#If (Test-Path -Path "$gamepath\src") { Remove-Item -Path "$gamepath\src" -Recurse -Force }
#Remove-Item -Path $gamepath\$subfolder -Recurse -Force
}
}
Function Write-Log {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias("LogContent")]
[string]$Message,
[Parameter(Mandatory = $false)]
[Alias('LogPath')]
[string]$Path = "$gamepath\$($SEGame)-Updater.log",
[Parameter(Mandatory = $false)]
[ValidateSet("Error", "Warn", "Info", "Debug")]
[string]$Level = "Info",
[Parameter(Mandatory = $false)]
[switch]$NoClobber
)
Begin {
# Set VerbosePreference to Continue so that verbose messages are displayed.
$VerbosePreference = 'Continue'
If (!($gamepath)) { Get-GamePath }
}
Process {
# If the file already exists and NoClobber was specified, do not write to the log.
If ((Test-Path $Path) -AND $NoClobber) {
Write-Error "Log file $Path already exists, and you specified NoClobber. Either delete the file or specify a different name."
Return
} ElseIf (!(Test-Path $Path)) {
# If attempting to write to a log file in a folder/path that doesn't exist create the file including the path.
Write-Verbose "Creating $Path."
New-Item $Path -Force -ItemType File
} Else {
# Nothing to see here yet.
}
# Format Date for our Log File
$FormattedDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
# Write message to error, warning, or verbose pipeline and specify $LevelText
Switch ($Level) {
'Error' {
Write-Error $Message
$LevelText = 'ERROR:'
}
'Warn' {
Write-Warning $Message
$LevelText = 'WARNING:'
}
'Info' {
Write-Verbose $Message
$LevelText = 'INFO:'
}
'Debug' {
Write-Verbose $Message
$LevelText = 'DEBUG:'
}
}
# Write log entry to $Path
"$FormattedDate $LevelText $Message" | Out-File -FilePath $Path -Append -Encoding ascii
Write-Host "$FormattedDate $LevelText $Message"
}
}
$NexusAPIRquired = @("F76SFE", "OBSE64", "SFSE", "SKSEVR", "SKSE", "FOSE", "MWSE")
If ($SEGame -in $NexusAPIRquired) {
If (-not $nexusAPI) {
Write-Error -Message "NexusMods SSED API key is required for $SEGame, visit https://next.nexusmods.com/settings/api-keys#:~:text=Silverlock%20Script%20Extender%20Downloader to acquire one!"
Exit 1
}
}
# Set some variables for much older silverlock.org versions
#$url = "https://$($SEGame).silverlock.org/"
#$rtype = "beta" # Release Type, Beta or Download
# Build the primary game and DLL variables
If ($SEGame -eq "SKSE64") {
$GameName = "Skyrim Special Edition"
Get-GitHubMod -url "https://api.github.com/repos/ianpatt/$($SEGame)/releases"
} ElseIf ($SEGame -eq "SKSEVR") {
# TODO Need to validate
$GameName = "Skyrim VR"
Get-NexusMods -nexusmodID "30457" -nexusgameID "skyrimspecialedition" -nexusfileindex "0"
} ElseIf ($SEGame -eq "SKSE") {
# TODO Need to validate
$GameName = "Skyrim"
Get-NexusMods -nexusmodID "100216" -nexusgameID "skyrim" -nexusfileindex "0"
} ElseIf ($SEGame -eq "OBSE") {
# TODO Need to validate
$GameName = "Oblivion"
Get-GitHubMod -url "https://api.github.com/repos/llde/xOBSE/releases"
} ElseIf ($SEGame -eq "OBSE64") {
$GameName = "Oblivion Remastered"
Get-NexusMods -nexusmodID "282" -nexusgameID "oblivionremastered" -nexusfileindex "-1"
} ElseIf ($SEGame -eq "F4SE") {
$GameName = "Fallout4"
# 20240718 - Adding new code to check the game version and determine the correct F4SE version to download due to the overhaul patch in April 2024
# This is going to be weird for a while, until ianpatt adds the 0.7.2 release to the Github repo (currently only available on NexusMods)
# Also this is in prep for Fallout: London, which will only work with the pre-overhaul patch version of Fallout 4
Get-GamePath
$currentGameVer = (Get-Item "$gamepath\Fallout4.exe").VersionInfo.FileVersion
If ($currentGameVer -eq "1.10.163.0") {
Write-Log -Level Debug -Message "Fallout 4 version 1.10.163.0 is pre-overhaul patch, and uses F4SE 0.6.23, specifically for Fallout: London"
Get-GitHubMod -url "https://api.github.com/repos/ianpatt/$($SEGame)/releases"
} Else {
# otherwise assume the game is post-overhaul patch, and uses F4SE 0.7.2+ from NexusMods
Get-NexusMods -nexusmodID "42147" -nexusgameID "fallout4" -nexusfileindex "-1"
}
} ElseIf ($SEGame -eq "F76SFE") {
$GameName = "Fallout76"
Get-NexusMods -nexusmodID "287" -nexusgameID "fallout76" -nexusfileindex "-1"
# And because SFE isn't exactly standard, we have to do some extra parsing.
Get-CurrentVersion
$subfolder = ($dl.file).Replace('.zip', '')
$global:useSubfolder = $true
} ElseIf ($SEGame -eq "NVSE") {
$GameName = "Fallout New Vegas"
# NVSE went to a community Github in May 2020
# https://github.com/xNVSE/NVSE
Get-GitHubMod -url "https://api.github.com/repos/xNVSE/$($SEGame)/releases"
$global:useSubfolder = $true
} ElseIf ($SEGame -eq "FOSE") {
# https://www.nexusmods.com/fallout3/mods/8606
$GameName = "Fallout 3"
Get-NexusMods -nexusmodID "8606" -nexusgameID "fallout3" -nexusfileindex "-1"
} ElseIf ($SEGame -eq "MWSE") {
# TODO Need to validate
$GameName = "Morrowind"
Get-NexusMods -nexusmodID "45468" -nexusgameID "morrowind" -nexusfileindex "-1"
} ElseIf ($SEGame -eq "SFSE") {
$GameName = "Starfield"
Get-NexusMods -nexusmodID "106" -nexusgameID "starfield" -nexusfileindex "-1"
$global:useSubfolder = $true
}
If (!($halt)) {
If ($null -eq $gamepath) { Get-GamePath }
Get-CurrentVersion
# Compare versions, download if source is newer than local
If (($dl.ver -gt $global:currentSE) -or ($forceDL -eq $true)) {
Write-Log -Message "Source version ($($dl.ver)) is higher than Local version ($global:currentSE)" -Level Warn
Get-Download -downloadURL $dl.url -downloadFile $dl.file -extractPath "$gamepath" -saveDir "$env:USERPROFILE\Downloads"
} Else {
Write-Log -Message "Source version ($($dl.ver)) is NOT higher than Local version ($global:currentSE), no action taken" -Level Info
}
If ($RunGame -eq "true") {
If ($SEGame -eq "F76SFE") {
Write-Log -Message "RunGame flag True, running Fallout76.exe" -Level Info
Start-Process -FilePath "$gamepath\Fallout76.exe" -WorkingDirectory $gamepath -PassThru
# If a window named "SFE" is found, that means SFE is incompatible with the current game version, end the Fallout76.exe task tree, archive the dxgi.dll file, and relaunch Fallout76.exe.
Start-Sleep -Seconds 5
$sfeOOD = Get-Process | Where-Object { $_.MainWindowTitle -eq "SFE" }
If ($sfeOOD) {
<#
Write-Log -Message "SFE is incompatible with the current game version, archiving dxgi.dll and relaunching Fallout76.exe" -Level Warn
Stop-Process -Name "Fallout76" -Force
# Rename dxgi.dll to SFE-<version>-dxgi.dll, if SFE-<version>-dxgi.dll exists, delete dxgi.dll
If (!(Test-Path "$gamepath\SFE-$($dl.ver)-dxgi.dll")) {
Rename-Item -Path "$gamepath\dxgi.dll" -NewName "SFE-$($dl.ver)-dxgi.dll" -Force
} Else {
Remove-Item -Path "$gamepath\dxgi.dll" -Force
}
Start-Process -FilePath "$gamepath\Fallout76.exe" -WorkingDirectory $gamepath -PassThru
#>
Write-Log -Message "SFE is incompatible with the current game version, looping to close error message" -Level Warn
# Message pops up 3 times, first is immediate, second takes ~12 seconds, third is less than 5 seconds after that
$i = 0
$counter = 0
Do {
Start-Sleep -Seconds 1
If (Get-Process | Where-Object { $_.MainWindowTitle -eq "SFE" }) {
If (!($wshell)) { $wshell = New-Object -ComObject wscript.shell }
$wshell.AppActivate('SFE')
Start-Sleep 1
$wshell.SendKeys('%C')
$wshell.AppActivate('SFE')
Start-Sleep 1
$wshell.SendKeys('{ENTER}')
$i++
}
$counter++
} Until ($i -eq 3 -or $counter -eq 45)
}
} Else {
Write-Log -Message "RunGame flag True, running $($SEGame)_loader.exe" -Level Info
Start-Process -FilePath "$gamepath\$($SEGame)_loader.exe" -WorkingDirectory $gamepath -PassThru
}
}
}
# SIG # Begin signature block
# MIIYnwYJKoZIhvcNAQcCoIIYkDCCGIwCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDOGOeLn4iN98nl
# eZWtNFEJ5tA3Z+7lKH2Hg4KuH3Trz6CCB0IwggN5MIIC/qADAgECAhAcz51nzeIZ
# /xLZmv82guWnMAoGCCqGSM49BAMDMHwxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVU
# ZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
# MTEwLwYDVQQDDChTU0wuY29tIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg
# RUNDMB4XDTE5MDMwNzE5MzU0N1oXDTM0MDMwMzE5MzU0N1oweDELMAkGA1UEBhMC
# VVMxDjAMBgNVBAg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