TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Bluetooth

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 704 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Christopher Zúñiga sotoC Offline
      Christopher Zúñiga soto
      last edited by

      I wanted to ask if it is possible to turn bluetooth off and on through triggercmd.

      RussR 1 Reply Last reply Reply Quote 0
      • RussR Offline
        Russ @Christopher Zúñiga soto
        last edited by

        @Christopher-Zúñiga-soto, I assume you have Windows? I found this page with this powershell script:

        [CmdletBinding()] Param (
            [Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus
        )
        If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv }
        Add-Type -AssemblyName System.Runtime.WindowsRuntime
        $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
        Function Await($WinRtTask, $ResultType) {
            $asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
            $netTask = $asTask.Invoke($null, @($WinRtTask))
            $netTask.Wait(-1) | Out-Null
            $netTask.Result
        }
        [Windows.Devices.Radios.Radio,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
        [Windows.Devices.Radios.RadioAccessStatus,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
        Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
        $radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]])
        $bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }
        [Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
        Await ($bluetooth.SetStateAsync($BluetoothStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
        

        It worked for me. You can run it with this command:

        powershell -command c:\scripts\bluetooth.ps1 -BluetoothStatus Off
        

        I watched it toggle this setting on and off:
        23703d8b-e920-45a9-b9a2-720f1c4cf4df-image.png

        Russell VanderMey

        Christopher Zúñiga sotoC 1 Reply Last reply Reply Quote 0
        • Christopher Zúñiga sotoC Offline
          Christopher Zúñiga soto @Russ
          last edited by

          @Russ I apologize for not specifying, it is the first time I try to do this kind of things. I honestly do not know how I could activate what you point out, if you could guide me it would be of great help. Thank you very much in advance.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post