Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# :
- @ECHO OFF
- where pwsh >NUL 2>&1
- IF ERRORLEVEL 1 (
- where winget
- IF NOT ERRORLEVEL 1 (
- echo Starting Powershell 7 install
- winget search --id Microsoft.Powershell --source winget
- ) ELSE (
- echo Download and install Powershell 7 then run the script again
- sleep 2
- start "" "https://learn.microsoft.com/it-it/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3#msi"
- pause
- exit
- )
- )
- net file 1>NUL 2>NUL
- if not '%errorlevel%' == '0' (
- pwsh -c Start-Process -FilePath ""%0"" -verb runas >NUL 2>&1
- exit /b
- )
- pwsh /nologo /noprofile /command ^
- "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
- exit /b
- #>
- # pwsh code here
- If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
- {
- Write-Host "NAAAH si è buggato fratm" -ForegroundColor Red
- pause
- exit
- }
- [console]::CursorVisible = $false
- function Write-OK {
- Write-Host "`r[ " -NoNewLine
- Write-Host "OK " -ForegroundColor Green
- }
- function Write-NO {
- Write-Host "`r[ " -NoNewLine
- Write-Host "NO " -ForegroundColor Red
- }
- # se non c'è
- # RUN ONCE
- if (!$(Get-NetFirewallRule -DisplayName "Block Steam" 2> $null)) {
- try {
- $steam = (Get-Process -Name Steam -ErrorAction Stop).Path
- }
- catch {
- Write-Error "Avvia Steam e riapri"
- pause
- break
- }
- # 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.
- netsh advfirewall firewall add rule name="Block steam" dir=in remoteip=0.0.0.0-191.254.254.254 program="$steam" action=block
- netsh advfirewall firewall add rule name="Block steam" dir=in remoteip=192.168.2.100-254.254.254.253 program="$steam" action=block
- netsh advfirewall firewall add rule name="Block steam" dir=out remoteip=0.0.0.0-191.254.254.254 program="$steam" action=block
- netsh advfirewall firewall add rule name="Block steam" dir=out remoteip=192.168.2.100-254.254.254.253 program="$steam" action=block
- }
- netsh advfirewall firewall set rule name="Block steam" new enable=no >$null
- Write-Host -NoNewLine "[ .... ] Starting Hogwarts Legacy"
- Start-Process "steam://rungameid/990080"
- if (!$?) {pause}
- do{
- Start-Sleep -Milliseconds 100
- Write-Host -NoNewLine "`r[ ... ]"
- Start-Sleep -Milliseconds 100
- Write-Host -NoNewLine "`r[ . .. ]"
- Start-Sleep -Milliseconds 100
- Write-Host -NoNewLine "`r[ .. . ]"
- Start-Sleep -Milliseconds 100
- Write-Host -NoNewLine "`r[ ... ]"
- Start-Sleep -Milliseconds 100
- Write-Host -NoNewLine "`r[ .... ]"
- }
- until (Get-Process | Where-Object {$_.path -match "HogwartsLegacy"})
- Write-OK
- Write-Host "[ INFO ] Game Started`n"
- # aspetta 4min prima di bloccare
- Write-Progress -Activity "Waiting" -Status "240..." -PercentComplete 1
- 1..240 | ForEach-Object {
- $percent = $_ * 100 / 240
- Write-Progress -Activity "Waiting" -Status "$(240 - $_)..." -PercentComplete $percent
- Start-Sleep -Seconds 1
- }
- Write-Progress -Activity "Waiting" -Status " " -Completed
- Write-Host -NoNewLine "[ .... ] Blocking Steam connection"
- $out = netsh advfirewall firewall set rule name="Block steam" new enable=yes
- if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
- Write-Host -NoNewLine "`n[ .... ] Waiting for game to close"
- Wait-Process -Name HogwartsLegacy
- if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
- Write-Host "[ INFO ] Game Closed`n"
- Write-Host -NoNewLine "[ .... ] Restoring Steam connection"
- $out = netsh advfirewall firewall set rule name="Block steam" new enable=no
- if ($?) {Write-OK} else {Write-NO; Write-Error "$out";pause;break}
- Write-Host `nDone - Aspetta che Steam torni online prima di riaprire il gioco
- Write-Host Altrimenti fai gioca subito non sono la tua vera madre
- sleep 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement