Windows系统下后台启动UWAMP、获取就绪通知及无托盘启动方案咨询
Alright, let's tackle your two UWAMP-related questions step by step — I've dealt with similar annoyances before, so here's what actually works:
First, getting UWAMP to run silently in the background without popping up windows or trays takes a little workaround, since the standard start -WindowStyle Hidden doesn't play nice with its process structure. Here's how to do it:
Background Launch Method
Use a VBScript to launch UWAMP with hidden windows — this bypasses the limitations of the start command. Create a file named start_uwamp_bg.vbs with this code:
Set WshShell = CreateObject("WScript.Shell") ' Replace the path with your actual UWAMP installation directory WshShell.Run """C:\UwAmp\uwamp.exe"" -start", 0, False
- The
0flag forces the window to stay hidden Falselets the script exit immediately instead of waiting for UWAMP to close
Double-click the VBS file, and UWAMP will fire up all enabled services in the background.
Get Ready Notifications
To confirm when your servers are fully up, pick one of these methods:
1. Port Status Check (Quick & Reliable)
Use PowerShell to monitor the default ports for Apache (80) and MySQL (3306). Create a check_ready.ps1 script:
# Wait for Apache to be ready while (-not (Test-NetConnection localhost -Port 80 -InformationLevel Quiet)) { Start-Sleep 1 } Write-Host "✅ Apache is ready to go!" # Wait for MySQL to be ready while (-not (Test-NetConnection localhost -Port 3306 -InformationLevel Quiet)) { Start-Sleep 1 } Write-Host "✅ MySQL is ready to go!" # Optional: Pop a Windows toast notification [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null $template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01) $textNodes = $template.GetElementsByTagName("text") $textNodes.Item(0).AppendChild($template.CreateTextNode("UWAMP Services Are Ready!")) > $null $toast = [Windows.UI.Notifications.ToastNotification]::new($template) [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("UWAMP Server").Show($toast)
Run this script right after launching UWAMP, and it'll alert you once both services are online.
2. Log File Monitoring
If you prefer checking server logs (more accurate for complex setups), monitor Apache's error log for its "ready" message. Add this to your PowerShell script:
$apacheLog = "C:\UwAmp\logs\error.log" $watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = Split-Path $apacheLog $watcher.Filter = Split-Path $apacheLog -Leaf $watcher.EnableRaisingEvents = $true Register-ObjectEvent $watcher "Changed" -Action { $logContent = Get-Content $Event.SourceEventArgs.FullPath | Select-String "configured -- resuming normal operations" if ($logContent) { Write-Host "✅ Apache is fully initialized!" Unregister-Event $EventSubscriber.SourceIdentifier $watcher.Dispose() } } | Out-Null # Repeat similar logic for MySQL's error log if needed
The start -WindowStyle Hidden fails because UWAMP's main process spawns child windows that bypass the hidden flag. Here are three solid workarounds:
Option 1: Launch Each Service Directly (Bypass UWAMP)
UWAMP is just a wrapper around standalone Apache, MySQL, and PHP binaries. You can launch each one directly with a hidden window using VBScript. Create a start_services_bg.vbs file:
Set WshShell = CreateObject("WScript.Shell") ' Launch Apache (update paths to match your UWAMP version) WshShell.Run """C:\UwAmp\bin\apache\apache2.4.54\bin\httpd.exe"" -f ""C:\UwAmp\conf\apache\httpd.conf""", 0, False ' Launch MySQL WshShell.Run """C:\UwAmp\bin\mysql\mysql8.0.30\bin\mysqld.exe"" --defaults-file=""C:\UwAmp\conf\mysql\my.ini""", 0, False ' Launch PHP-FPM (if you use it) WshShell.Run """C:\UwAmp\bin\php\php8.1.10\php-fpm.exe"" --fpm-config ""C:\UwAmp\conf\php\php-fpm.conf""", 0, False
This starts each service independently, no tray icons, no windows — pure background execution.
Option 2: Register Services with NSSM (Permanent Background Solution)
Use NSSM (Non-Sucking Service Manager) to turn each server into a Windows system service. This lets them run in the background even when you're logged out, and you can set them to auto-start on boot.
- Download NSSM (match your system's 32/64-bit architecture) and place it in your UWAMP directory or
C:\Windows\System32. - Open an elevated Command Prompt (Run as Administrator) and run:
A GUI will pop up:nssm install UWAMP-Apache- In
Path, select your Apachehttpd.exe(e.g.,C:\UwAmp\bin\apache\apache2.4.54\bin\httpd.exe) - In
Arguments, add-f "C:\UwAmp\conf\apache\httpd.conf" - Click
Install service
- In
- Repeat for MySQL:
nssm install UWAMP-MySQL- Path:
C:\UwAmp\bin\mysql\mysql8.0.30\bin\mysqld.exe - Arguments:
--defaults-file="C:\UwAmp\conf\mysql\my.ini"
- Path:
- Start the services with:
You can manage these services via Windows' Services panel (net start UWAMP-Apache net start UWAMP-MySQLservices.msc) anytime.
Option 3: Disable UWAMP Tray Icon via Config (Version-Dependent)
Some UWAMP versions let you disable the tray icon directly in its config file:
- Open
C:\UwAmp\config\uwamp.ini(oruwamp.confdepending on your version) - Look for a line like
ShowTrayIcon=1and change it toShowTrayIcon=0 - Save the file, then use the VBScript method from Question 1 to launch UWAMP — no tray icon will appear.
Note: This doesn't work for all UWAMP versions, so test it first.
内容的提问来源于stack exchange,提问作者abrejohn

