I am developing an auto launch tutorial, but Windows 7 has the slightly annoying prevention of running inf files. Is there away to get around this or am I stuck with it?

If there is not away would some one be able to assist me in writing a simple start up file that would start xampp, which launches my server, then start a website after the server is running?

Dani AI

Generated

Windows 7 blocks INF autorun on removable media for security, and re-enabling it system-wide is fragile (and often requires Group Policy or registry edits). Given that constraint and the Home-edition limitation mentioned by , a practical and safe approach is to ship a small double-clickable starter on the USB that launches XAMPP and opens the site once the server is listening. This avoids tinkering with system autorun settings (the tip from is useful for full-system tweaks, but a portable starter is simpler).

Try this batch pattern (save as start-site.bat and edit the variables at top to match your install):

@echo off
set "XAMPP_DIR=C:\xampp"
set "SITE_URL=http://localhost/"
set "PORT=80"
set "TIMEOUT=30"
set "APACHE_SERVICE=Apache2.4"
set "MYSQL_SERVICE=mysql"

sc query "%APACHE_SERVICE%" >nul 2>&1
if %errorlevel%==0 (
  echo Starting %APACHE_SERVICE%...
  sc start "%APACHE_SERVICE%" >nul 2>&1
) else if exist "%XAMPP_DIR%\apache_start.bat" (
  start "" "%XAMPP_DIR%\apache_start.bat"
) else if exist "%XAMPP_DIR%\xampp-control.exe" (
  start "" "%XAMPP_DIR%\xampp-control.exe"
)

sc query "%MYSQL_SERVICE%" >nul 2>&1
if %errorlevel%==0 (
  sc start "%MYSQL_SERVICE%" >nul 2>&1
) else if exist "%XAMPP_DIR%\mysql_start.bat" (
  start "" "%XAMPP_DIR%\mysql_start.bat"
)

echo Waiting up to %TIMEOUT% seconds for port %PORT%...
powershell -NoProfile -Command "$timeout=%TIMEOUT%; $t0=[datetime]::UtcNow; while (([datetime]::UtcNow - $t0).TotalSeconds -lt $timeout) { try { $c=New-Object System.Net.Sockets.TcpClient('127.0.0.1',%PORT%); $c.Close(); exit 0 } catch { Start-Sleep -Milliseconds 250 } }; exit 1"

if %errorlevel%==0 (
  start "" "%SITE_URL%"
) else (
  echo Server did not respond within %TIMEOUT% seconds.
)

Notes and troubleshooting:

  • Edit XAMPP_DIR, SITE_URL, PORT and service names to match your install. Use Services.msc to confirm exact service names if you installed Apache/MySQL as services.
  • Starting services via sc requires Administrator rights; run the batch as Administrator or create a scheduled task to run it elevated.
  • If Apache runs on a different port (e.g., 8080) or uses HTTPS, update PORT and SITE_URL accordingly.
  • If PowerShell is not available, replace the wait loop with a fixed timeout pause, but that is less reliable.

This gives an autorun-like user experience without trying to re-enable INF autorun on the host machine.

Recommended Answers

All 2 Replies

I have windows 7 home premium so I do not have gpedit to enable it. From what I have read you need to use gpedit to enable the autorun on the USB

Edit: thank you for the link though, it would have helped if I had a higher windows

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.