Open and Change Windows Settings via Powershell

Viewed 6595

Please let me know if this would be better asked in SuperUsers.

I know you can open Settings in powershell via:

Start-Process ms-settings:

But I want to open up in a specific location in settings (in this case, "Devices -> Pen & Windows Ink")

Start-Process "ms-settings:Devices\Pen & Windows Ink"

Okay, apparently that works :P I was just typing that as pseudo-code, but apparently it works. So never mind about that first part of the question.

[EDIT Yesterday, the above code worked, but now it doesn't. Since yesterday, I have made changes in the $profile document, but I can't see how what I did could have made this no longer work]

How would I toggle the "Ignore touch input when I'm using my pen" setting, such as this pseudo-code that better not work (or else that would just be scary)

Toggle-Setting "ms-settings:Device\Pen & Windows Ink\Ignore touch when I'm using my pen"

(Okay good, it doesn't work this time)

If you need to do something in the registry, please explain how to avoid messing up something important.

1 Answers

Well, the registry is your best option here. Other then that, you might be able by sending message to the windows once open but that would be the long (and breakable) way around.

To do the specific you want, use the following:

$registryPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows\Pen"
$GetValue = {Get-ItemPropertyValue -Path $registryPath -Name 'PenArbitrationType'}

Write-Host "Initial value is $($GetValue.Invoke())" -ForegroundColor Cyan
# on
Set-ItemProperty -Path $registryPath -Name 'PenArbitrationType' -Value 1
Write-Host "Item property is now set to: $($GetValue.Invoke()) "
# off 
Set-ItemProperty -Path $registryPath -Name 'PenArbitrationType' -Value 3
Write-Host "Item property is now set to: $($GetValue.Invoke()) "

You can see this in action if you open regedit, go to the path above, then use the UI to change the value manually. If you refresh your regedit, you will see that the value alternate between 1 (on) and 3 (off).

That's basically all the UI do for you when you toggle that setting.

Reference: Turn On or Off Ignore Touch Input when using Pen in Windows 10

Related