Category filter

Script to turn on/off location services for apps on Windows

As an IT administrator, you may need to enable or disable location services for all apps on company-owned devices to ensure compliance with your organization’s security and privacy policies. For instance, you may need to install or have already installed apps on your devices that require location access to render their services. To ensure these apps work properly on corporate devices, it is important to prevent users from denying access to the location. Alternatively, you may want to prevent apps on your devices from accessing locations to improve organizational security. You will need to restrict users from granting location services in such cases. Regardless of the requirement, you can employ Hexnode’s Execute Custom Script action to forcefully turn on/off location services for apps on your Windows devices.

Disclaimer:

The sample scripts provided below are adapted from third-party open-source sites.

Allow apps to access location services

Run the below script to allow all apps to access location services. Once the script is executed, users cannot make changes denying apps access to location services.

Batch Script

PowerShell Script

Once the script is executed successfully, you can see the toggle button turned on and greyed out:

Turn on location services for apps on Windows

Deny apps access to location services

Run the below script to forcefully deny all apps from accessing location services. Once the script is executed, users cannot make changes that allow apps to access the location services.

Batch Script

PowerShell Script

Once the script is executed successfully, you can see the toggle button turned off and greyed out:

Turn off location services for apps on Windows

Note:

  • To re-enable users to allow/deny access to location services, run the above scripts by assigning the value ‘0’ instead of ‘1’ for the Reg_Dword entry named LetAppsAccessLocation.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository