Skip to content

Commit

Permalink
now auto-restarts httpd.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Dalton committed Apr 9, 2019
1 parent 810897d commit 62de002
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# xampp-apache-rightclick-cd
A right-click context-menu item helper that'll swap XAMPP's Apache's directory with a newly desired directory.
A right-click context-menu item helper that'll swap XAMPP's Apache's directory with a newly desired directory,
and then restart Apache to update its configuration.

# Installation

Expand Down Expand Up @@ -36,8 +37,17 @@ The program depends on `httpd.conf` to be in `C:\xampp\apache\httpd.conf`.
If you'd like to change where this is, simply change the required variable in `Program.cs`
and recompile.

# `httpd.exe` location

The program depends on `httpd.exe` (the Apache host process) to be in `C:\xampp\apache\bin\httpd.exe`.
If you'd like to change where this is, simply change the required variable in `Program.cs`
and recompile.

# Dependencies

XAMPP is required (as it's meant to change XAMPP settings). For easier use, use XAMPP's default location
on your C drive (`C:\xampp`).

Due to being in C#, the .NET environment (specifically, version 2.1) is required.
The DLLs necessary for it to run are attached in the release zip files.

Expand Down
23 changes: 22 additions & 1 deletion xampp-apache-rightclick-cd/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using System;
using System.Threading;
using System.Diagnostics;

namespace xampp_apache_rightclick_cd
{
Expand All @@ -13,6 +13,11 @@ class Program
**/
static string httpd_conf = "C:\\xampp\\apache\\conf\\httpd.conf";

/**
* Change me if your httpd.exe is NOT C:\xampp\apache\bin\httpd.exe
**/
static string httpd_loc = "C:\\xampp\\apache\\bin\\httpd.exe";

/**
* Use for debugging
**/
Expand All @@ -24,11 +29,27 @@ static int Main(string[] args)
{
string wd = Directory.GetCurrentDirectory();

foreach (Process process in Process.GetProcessesByName("httpd"))
{
Console.WriteLine("Stopping httpd (PID " + process.Id + " ...");
process.Kill();
}

Parser p = new Parser(httpd_conf, wd, Debug);

p.Parse();

Console.WriteLine("Done.");

pause();

Console.WriteLine("Starting httpd...");

Process httpd_proc = new Process();
httpd_proc.StartInfo.CreateNoWindow = true;
httpd_proc.StartInfo.UseShellExecute = false;
httpd_proc.StartInfo.FileName = httpd_loc;
httpd_proc.Start();
} catch (Exception e)
{
err(e);
Expand Down

0 comments on commit 62de002

Please sign in to comment.