Just add the option to use CMD or PS in the Config UI and run a .ps1 that executes the .bat
Example xampp_shell.ps1:
- Code: Select all
./xampp_shell.bat
It loads the batch file into PS while retaining the PS commands as well.
Just a suggestion.
==== EDIT ====
I've gone and written a version just for PS users. Code is pasted below.
- Code: Select all
<#
xampp_shell.ps1 PowerShell script by Kaleb Klein
You are free to use this script, modify, distribute, or whatever
you feel like doing with it. Based upon Apache Friends' xampp_shell.bat
Windows 8 is needed to natively run this, though if PS is installed
on your version of Windows, please enjoy :)
#>
$host.UI.RawUI.WindowTitle = "XAMPP for Windows"
$version = "1.0"
""
"Setting environment for using XAMPP for Windows"
# Initialize Environment Vars and Path
$curdir = $(get-location)
$mibdirs = "$curdir\extras\mibs\"
$mysql = "$curdir\mysql\bin\"
$php_pear_sysconf_dir = "$curdir\php\"
$php_pear_bin_dir = "$curdir\php\"
$php_pear_test_dir = "$curdir\php\tests\"
$php_pear_www_dir = "$curdir\php\www\"
$php_pear_cfg_dir = "$curdir\php\cfg\"
$php_pear_data_dir = "$curdir\php\data\"
$php_pear_doc_dir = "$curdir\php\docs\"
$php_pear_php_bin = "$curdir\php\php.exe\"
$php_pear_install_dir = "$curdir\php\pear\"
$phprc = "$curdir\php\"
$tmp = "$curdir\tmp\"
$perl5lib = $null
$env:Path = $env:Path + ";$mysql;$php_pear_bin_dir;$php_pear_test_dir;$php_pear_www_dir;$php_pear_cfg_dir;$php_pear_data_dir;$php_pear_doc_dir;$php_pear_php_bin;$php_pear_install_dir;$phprc;$tmp;$perl5lib"
# Initial Command var set to null
$command = $null
# a little help function to display XFW specific commands
function show_help
{
clear
""
"XAMPP for Windows PowerShell Console v$version"
""
"Current built in commands that are XFW specific:"
"exit - Exits console"
"quit - See exit"
"help - Shows this"
""
"All other functions from CMD version of XFW Shell"
"are also included in here."
""
"This console was built to incorperate all XAMPP console features as well as"
"All PowerShell features for all the PS lovers out there!"
""
}
# prompt function for displaying USERNAME@COMPUTERNAME LOCATION text
function prompt
{
cd $curdir
Write-Host($env:USERNAME) -NoNewline -ForegroundColor Green
Write-Host("@") -NoNewline -ForegroundColor Red
Write-Host($env:COMPUTERNAME) -NoNewline -ForegroundColor Green
Write-Host(" " + $(get-location))
}
# run command function to process commands supplied by user
function run_command($command)
{
switch($command)
{
"exit" { exit }
"quit" { exit }
"help" { show_help }
default
{
Try
{
Invoke-Expression $command
}
Catch [system.exception]
{
Write-Host("Error: ") -NoNewline -ForegroundColor Red
Write-Host("The command ") -NoNewline
Write-Host("'" + $command + "'") -NoNewline -ForegroundColor Yellow
Write-Host(" is not a valid command!")
Write-Host("")
}
}
}
}
# think of this as the main function. Run this to run the shell
function start_shell
{
# Main loop. Continue loop until command "exit" is given
while($true)
{
""
prompt # run prompt function to display USERNAME@COMPUTERNAME LOCATION text
$command = Read-Host "#" # set command var to user's input
# check if user supplies input
if($command -ne "")
{
# Hack for attempting to fix cd command
if($command.StartsWith("cd "))
{
$loc = $command.Substring(3)
if($loc.Contains(":\"))
{
$curdir = $loc
}
else
{
$curdir = "$curdir\$loc"
}
}
else
{
# Try to execute user's input
# run exception if command cannot be run
# allows for running XAMPP specific programs while keeping all PS commands open
run_command($command)
}
}
}
}
start_shell # Start shell
Just save this in the xampp root directory and double-click the file. Save it as xampp_shell.ps1 and make sure .ps1 is the extension.
Be sure to set the execution policy for PS to RemoteSigned so you can run the script.
Run
- Code: Select all
Get-ExecutionPolicy
- Code: Select all
Set-ExecutionPolicy RemoteSigned
XAMPP Dev Team, please give the option to select between the two so I don't have to open explorer and run it manually.