Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Windows Sensor

Aug
1,929
70
Code:
e:\utils>whatver
     _x64: 1
   _admin: 1
_elevated: 1

TCC  25.00.7 x64   Windows 10 [Version 10.0.18362.175]

I'm testing out the GPS internal variables, but keep getting "Element not found";
Code:
e:\utils>echo %_gpslon
Element not found.

e:\utils>echo %_gpslat
Element not found.

I can access GPS properties via PowerShell;
Code:
PS E:\utils> type .\latlong1.ps1
Add-Type -AssemblyName System.Device
$GPS = New-Object System.Device.Location.GeoCoordinateWatcher
$GPS.Start()

while (($GPS.Status -ne 'Ready') -and ($GPS.Permission -ne 'Denied')) {
    Start-Sleep -Milliseconds 100
}

if ($GPS.Permission -eq 'Denied'){
    Write-Error 'Access Denied for Location Information'
} else {
    $GPS.Position.Location | Select Latitude,Longitude
}
PS E:\utils> .\latlong1.ps1

        Latitude         Longitude
        --------         ---------
42.9562811439727 -81.2781491520377

The help says the _gps* require a GPS that supports the Windows Sensor Location APIs.

If I can access GPS info via PowerShell, why can I not access GPS info via TCC?

Joe
 
My Windows 10/TCC 25 system is connected to my cell phone, via HotSpot, from which it gets the GPS info.

Joe
 
Microsoft supports it.

If I disable Location Access via the Control Panel, my PowerShell script returns;
Code:
PS E:\utils> .\LatLong1.ps1
E:\utils\LatLong1.ps1 : Access Denied for Location Information
At line:1 char:1
+ .\LatLong1.ps1
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,LatLong1.ps1

When I re-enable Location Access via the Control Panel, my PowerShell script works as it should;
Code:
PS E:\utils> .\LatLong1.ps1

        Latitude         Longitude
        --------         ---------
42.9562720571419 -81.2781380584523

Joe
 

Similar threads

Back
Top