Rubyで。Apache (XAMPP for Windows内) のDocumentRootを変える。
頻繁に変えるので対処した。Apacheの再起動はXAMPP controllerからやって。
@echo off rem license: Public Domain <utakata.c4se@gmail.com> ruby -x %~f0 %* @goto :eof #!ruby # coding=utf-8 $HTTPD_CONF_PATH = 'C:\\xampp\\apache\\conf\\httpd.conf' def change_httpd_docroot new_docroot httpd_conf = open($HTTPD_CONF_PATH, 'r:utf-8').read regex = /^DocumentRoot\s+".+"/ puts "From\t#{regex.match(httpd_conf)[0]}" httpd_conf = httpd_conf.sub regex, %Q{DocumentRoot "#{new_docroot}"} puts "To\t#{regex.match(httpd_conf)[0]}" open($HTTPD_CONF_PATH, 'w:utf-8').write httpd_conf end ARGV[0] = Dir.pwd unless ARGV[0] if /^-+h/.match ARGV[0] puts DATA.read exit end new_docroot = ARGV[0].encode('utf-8').gsub /\\/, '/' change_httpd_docroot new_docroot __END__ change_httpd_docroot [-option] [new_documentroot] Change httpd.conf DocumentRoot Options: --help | -h Print this help.
cf. Windos版whichコマンド (*nix `which` command on Windows (need Ruby).) - c4se記:さっちゃんですよ☆ http://c4se.hatenablog.com/entry/2013/03/24/061210
batch file中にRubyを書く方法