איל_משולשהאט געשריבן:↑פרייטאג אוגוסט 09, 2024 5:46 pm
כ'האב נאר נישט מצליח געווען צו טרעפן די js פייל אויף קלאודפלעיר... איך קען נישט טרעפן די url. נישט אין בראוזער, און נישט מיט curl. דו האסט יא געזען וואס ער טוט אינעם פראקסי?
# Define business hours (24-hour format)
$startTime = "09:00"
$endTime = "14:00"
# Define the website to block
$website = "www.ivelt.com"
# Path to the hosts file
$hostsFile = "$env:windir\System32\drivers\etc\hosts"
# IP to redirect to (usually localhost)
$redirectIP = "127.0.0.1"
# Line to add to hosts file
$hostEntry = "$redirectIP $website"
# Function to check if current time is within specified hours
function Is-BlockTime {
$currentTime = Get-Date -Format "HH:mm"
return ($currentTime -ge $startTime -and $currentTime -le $endTime)
}
# Function to add website to hosts file
function Block-Website {
if (-not (Select-String -Path $hostsFile -Pattern $website -Quiet)) {
Add-Content -Path $hostsFile -Value $hostEntry -Force
Write-Output "Added $website to hosts file. It is now blocked."
} else {
Write-Output "$website is already in the hosts file."
}
}
# Function to remove website from hosts file
function Unblock-Website {
(Get-Content $hostsFile) | Where-Object { $_ -notmatch $website } | Set-Content $hostsFile
Write-Output "Removed $website from hosts file. It is now unblocked."
}
# Main script
if (Is-BlockTime) {
Block-Website
} else {
Unblock-Website
}
To use this script:
Save it as a .ps1 file (e.g., BlockIvelt.ps1). The script is set to block ivelt.com from 9 AM to 2 PM. Adjust the $startTime and $endTime variables if needed.
To schedule this script:
Open Task Scheduler on your Windows machine.
Create a new task.
Set it to run with highest privileges (important for modifying the hosts file).
Schedule it to run every few minutes or at specific times.
Use this action: powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\BlockIvelt.ps1"