Skip to content

Instantly share code, notes, and snippets.

@johnstevenson
johnstevenson / elevate-demo2.php
Last active Jul 4, 2020
Composer self-update as admin
View elevate-demo2.php
<?php
/**
* This demo shows a method for elevating to an Admin on Windows and running
* a command in cmd.exe, from a PHP script. It demonstrates how Composer can
* self-update to an Admin location.
*
* Note that it creates composer-phar.txt file in the current directory.
*/
@johnstevenson
johnstevenson / elevate-demo.php
Created May 6, 2020
Demo showing how composer self-update can elevate to
View elevate-demo.php
<?php
/**
* This demo shows a method for elevating to an Admin on Windows and running
* a command in cmd.exe, from a PHP script. It demonstrates how Composer can
* self-update to an Admin location.
*
* Powershell (available on Windows 7 upwards) is used to invoke the UAC prompt,
* because it returns a value from the result of the prompt so we can see if the
* user cancelled. Note that it is impossible to obtain the exit code from the
@johnstevenson
johnstevenson / inno6-resize.iss
Created Mar 16, 2019
Inno 6 - bug when resizing dynamically set TNewStaticText captions
View inno6-resize.iss
; -- inno6-resize.iss --
; Demonstrates TNewStaticText not resizing when set dynamically
[Setup]
AppName=Composer
AppVersion=5.0
WizardStyle=modern
CreateAppDir=no
DisableProgramGroupPage=yes
OutputDir=userdocs:Inno Setup Examples Output
@johnstevenson
johnstevenson / restart.php
Last active Jan 29, 2018
PHP Windows opcache-xdebug crash
View restart.php
<?php
if (!getenv('RESTART_TEST')) {
showExtensionInfo();
putenv('RESTART_TEST=1');
putenv('PHP_INI_SCAN_DIR=');
$iniFiles = getIniFiles();
$tmpIni = writeTmpIni($iniFiles);
@johnstevenson
johnstevenson / WindowsUserEnvironment.php
Created Sep 30, 2014
Modify user environment variables in the Windows registry
View WindowsUserEnvironment.php
<?php
/*
* Classes to modify User environment variables in the Windows registry
*
* Warning:
* Use at your own discretion and with care. It would be quite easy to
* make a system unstable by adding or modifying certain values.
*
* Ensure that this code works for you by testing it first (create a
* Restore Point or backup your HKCU\Environment key beforehand).