-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathToggleDNS.ps1
More file actions
47 lines (37 loc) · 1.44 KB
/
ToggleDNS.ps1
File metadata and controls
47 lines (37 loc) · 1.44 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
# Get the Cloudflare WARP service
$WARPService = Get-Service -Name "Cloudflare WARP" -ErrorAction SilentlyContinue
if ($WARPService -and $WARPService.Status -eq 'Running') {
# --- STOP SEQUENCE ---
Write-Host "Cloudflare WARP is running. Stopping it..."
# Disconnect using warp-cli
Write-Host "Disconnecting Cloudflare..."
warp-cli disconnect
Start-Sleep -Seconds 2
# Stop the service
Write-Host "Stopping Cloudflare Service."
Stop-Service -Name "Cloudflare WARP" -Force
# Stop the GUI application
$warpProcess = Get-Process -Name "Cloudflare WARP" -ErrorAction SilentlyContinue
if ($warpProcess) {
Write-Host "Closing Cloudflare WARP application."
$warpProcess | Stop-Process -Force
}
Write-Host "Cloudflare WARP stopped successfully."
} else {
# --- START SEQUENCE ---
Write-Host "Cloudflare WARP is stopped. Starting it..."
# Start the service
Write-Host "Starting Cloudflare Service."
Start-Service -Name "Cloudflare WARP"
Start-Sleep -Seconds 3
# Connect using warp-cli
Write-Host "Connecting Cloudflare..."
warp-cli connect
# Start the GUI application
$warpProcess = Get-Process -Name "Cloudflare WARP" -ErrorAction SilentlyContinue
if (!($warpProcess)) {
Write-Host "Launching Cloudflare WARP application."
Start-Process "Cloudflare WARP.exe" -ErrorAction Stop
}
Write-Host "Cloudflare WARP started successfully."
}