aurumdigitus wrote:But such convoluted syntax. The sun would have gone nova before I ever came up with that.


heh...
Since SysNative is a virtual directory that is only visible in 32-bit apps, presumably only when 32-bit apps are run on 64-bit Windows, and since the possibility exists that XY might eventually become 64-bit, that should probably be even more convoluted.
To future proof it and make it more forgiving I think this would work but this is NOT tested:
Code: Select all
"System Properties Protection"
// Use existence of SysNative to detect 32-bit XY on 64-bit OS.
$cmd = "%SystemRoot%\SysNative\cmd.exe";
if (! exists($cmd)) {
// Not sure if we should fallback to ComSpec or System32 first.
$cmd = "%SystemRoot%\System32\cmd.exe"; // Could replace with XY-only: %WinSysDir%\cmd.exe
if (! exists($cmd)) {
$cmd = "%ComSpec%";
End ! Exists($cmd), "I give up trying to locate cmd.exe - go away!";
}
}
run """$cmd"" /C systempropertiesprotection",,, 0;
Fortunately, when XY's and the OS' architectures match there's probably no reason to run the command through cmd.exe so maybe even replace that with (again NOT tested):
Code: Select all
"System Properties Protection"
// Use existence of SysNative to detect 32-bit XY on 64-bit OS.
$cmd = "%SystemRoot%\SysNative\cmd.exe";
if (exists($cmd)) {
run """$cmd"" /C systempropertiesprotection",,, 0;
} else {
run 'systempropertiesprotection';
}
EDIT: Of course even if this was thoroughly tested 100% coverage can't be achieved until there's a 64-bit version of XY.
