Skip to content

Instantly share code, notes, and snippets.

@johnstevenson
johnstevenson / elevate-demo2.php
Last active July 4, 2020 13:20
Composer self-update as admin
<?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 17:57
Demo showing how composer self-update can elevate to
<?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 March 16, 2019 16:25
Inno 6 - bug when resizing dynamically set TNewStaticText captions
; -- 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 January 29, 2018 16:43
PHP Windows opcache-xdebug crash
<?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 September 30, 2014 12:13
Modify user environment variables in the Windows registry
<?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).