Google

2013-04-01

Change Location Settings via PowerShell

Today, I have seen a question on StackOverflow.com about how to turn on/off Location Settings in Windows 8 via PowerShell.

This setting is available in the Control Panel (Win + I > Control Panel), under "Location Settings".


To be able to locate the relevant registry key, I launched Procmon (aka. Process Monitor) from SysInternals. Anyone who used the application knows how overwhelming the data will be in just a few seconds of capture. So I had to be quick:

  • I started the capture, 
  • immediately cleared the checkbox next to "Turn on the Windows Location Platform", 
  • clicked Apply
  • And stopped Capture

Even though all that took a few secs, capture generated tens of thousands of events. I started from bottom, excluding all the irrelevant Operations, until I reached the one I am looking for "RegSetValue"





The path it referred to sounded promising:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{GUID}\SensorPermissionState

I checked another Windows 8 machine and confirmed that the GUID was the same:
Then, manually changed registry key from 0 to 1 and refresh Location Setting to confirm checkbox was back on.


Once that was done, doing it in PowerShell was quite trivial:

To turn on the Windows Location Platform set value to 1:


set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}' -Name SensorPermissionState -Value 0x1

To turn off the Windows Location Platform set value to 0:


set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}' -Name SensorPermissionState -Value 0x0

No comments: