Advertisement
tomhet

hogwarts legacy

Mar 14th, 2023 (edited)
1,452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.15 KB | None | 0 0
  1. <# :
  2.     @ECHO OFF
  3.         where pwsh >NUL 2>&1
  4.         IF ERRORLEVEL 1 (
  5.             where winget
  6.             IF NOT ERRORLEVEL 1 (
  7.                 echo Starting Powershell 7 install
  8.                 winget search --id Microsoft.Powershell --source winget
  9.             ) ELSE (
  10.                 echo Download and install Powershell 7 then run the script again
  11.                 sleep 2
  12.                 start "" "https://learn.microsoft.com/it-it/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3#msi"
  13.                 pause
  14.                 exit
  15.             )
  16.         )
  17.         net file 1>NUL 2>NUL
  18.         if not '%errorlevel%' == '0' (
  19.             pwsh -c Start-Process -FilePath ""%0"" -verb runas >NUL 2>&1
  20.             exit /b
  21.         )
  22.         pwsh /nologo /noprofile /command ^
  23.             "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
  24.     exit /b
  25. #>
  26. # pwsh code here
  27. If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
  28. {
  29.     Write-Host "NAAAH si è buggato fratm" -ForegroundColor Red
  30.     pause
  31.     exit
  32. }
  33. [console]::CursorVisible = $false
  34. function Write-OK {
  35.     Write-Host "`r[  " -NoNewLine
  36.     Write-Host "OK " -ForegroundColor Green
  37. }
  38. function Write-NO {
  39.     Write-Host "`r[  " -NoNewLine
  40.     Write-Host "NO " -ForegroundColor Red
  41. }
  42.  
  43. # se non c'è
  44. # RUN ONCE
  45. if (!$(Get-NetFirewallRule -DisplayName "Block Steam" 2> $null)) {
  46.     try {
  47.         $steam = (Get-Process -Name Steam -ErrorAction Stop).Path
  48.     }
  49.     catch {
  50.         Write-Error "Avvia Steam e riapri"
  51.         pause
  52.         break
  53.     }
  54.     # Allow ip range 192.0.0.1-192.168.2.249 and 254.254.254.254(allow broadcast for steamlink to find server) block all other ip addresses.
  55.     netsh advfirewall firewall add rule name="Block steam" dir=in remoteip=0.0.0.0-191.254.254.254 program="$steam" action=block
  56.     netsh advfirewall firewall add rule name="Block steam" dir=in remoteip=192.168.2.100-254.254.254.253 program="$steam" action=block
  57.     netsh advfirewall firewall add rule name="Block steam" dir=out remoteip=0.0.0.0-191.254.254.254 program="$steam" action=block
  58.     netsh advfirewall firewall add rule name="Block steam" dir=out remoteip=192.168.2.100-254.254.254.253 program="$steam" action=block
  59. }
  60.  
  61. netsh advfirewall firewall set rule name="Block steam" new enable=no >$null
  62.  
  63. Write-Host -NoNewLine "[ .... ] Starting Hogwarts Legacy"
  64. Start-Process "steam://rungameid/990080"
  65. if (!$?) {pause}
  66.  
  67. do{
  68.     Start-Sleep -Milliseconds 100
  69.     Write-Host -NoNewLine "`r[  ... ]"
  70.     Start-Sleep -Milliseconds 100
  71.     Write-Host -NoNewLine "`r[ . .. ]"
  72.     Start-Sleep -Milliseconds 100
  73.     Write-Host -NoNewLine "`r[ .. . ]"
  74.     Start-Sleep -Milliseconds 100
  75.     Write-Host -NoNewLine "`r[ ...  ]"
  76.     Start-Sleep -Milliseconds 100
  77.     Write-Host -NoNewLine "`r[ .... ]"
  78. }
  79. until (Get-Process | Where-Object {$_.path -match "HogwartsLegacy"})
  80. Write-OK
  81. Write-Host "[ INFO ] Game Started`n"
  82.  
  83. # aspetta 4min prima di bloccare
  84. Write-Progress -Activity "Waiting" -Status "240..." -PercentComplete 1
  85. 1..240 | ForEach-Object {
  86.     $percent = $_ * 100 / 240
  87.     Write-Progress -Activity "Waiting" -Status "$(240 - $_)..." -PercentComplete $percent
  88.     Start-Sleep -Seconds 1
  89. }
  90. Write-Progress -Activity "Waiting" -Status " " -Completed
  91.  
  92. Write-Host -NoNewLine "[ .... ] Blocking Steam connection"
  93. $out = netsh advfirewall firewall set rule name="Block steam" new enable=yes
  94. if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
  95.  
  96. Write-Host -NoNewLine "`n[ .... ] Waiting for game to close"
  97. Wait-Process -Name HogwartsLegacy
  98. if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
  99.  
  100. Write-Host "[ INFO ] Game Closed`n"
  101.  
  102. Write-Host -NoNewLine "[ .... ] Restoring Steam connection"
  103. $out = netsh advfirewall firewall set rule name="Block steam" new enable=no
  104. if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
  105. Write-Host `nDone - Aspetta che Steam torni online prima di riaprire il gioco
  106. Write-Host Altrimenti fai gioca subito non sono la tua vera madre
  107. sleep 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement