Background: Windows 10, for some unfathomable reason, has System Protection (i.e. System Restore) turned OFF by default. It's easy to turn back on again manually... but every automatic 'upgrade' turns it OFF again. I use an AHK 'Win 10 configurator' script so I don't have to spend ages on new installs remembering where all the settings are stored. I want to add a method to turn System Protection ON and configure the maximum amount of storage space to set aside for system restore points.
This is simplicity itself using an elevated PowerShell console:
Code: Select all
Enable-ComputerRestore -drive "C:\"
vssadmin resize shadowstorage /on=c: /for=c: /maxsize=10%
Code: Select all
If Not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
psScript =
(
Enable-ComputerRestore -drive "C:\"
vssadmin resize shadowstorage /on=c: /for=c: /maxsize=10%
)
; Use this call if you want to see PowerShell output
; -NonInteractive supresses the 'Cannot load PSReadline module. Console is running without PSReadline.' module error
; -NoExit prevents the PowerShell console from closing automatically so is useful for testing code
Run powershell.exe -NonInteractive -NoExit -Command %psScript%
So... does anyone know why the first PowerShell command-line doesn't work when wrapped in AHK and, secondly, how do I re-write the second command-line so the last parameter is not interpreted as a variable?
All suggestions/explanations, including working alternative methods, gratefully received ('cos I've spent hours so far trying to figure this out).