locked
script to enable and disable airplane mode RRS feed

  • Question

  • What powershell script, if any, can I use to turn on and off airplane mode on Windows 8.1?  The ZIP file at eightforums.com contains executables.
    • Moved by Bill_Stewart Wednesday, June 25, 2014 4:22 PM Question outside forum scope
    Friday, January 17, 2014 3:37 AM

All replies

  • Hi,

    I'm not finding a good way to do this via PowerShell after a quick search, but I've looked over the files you've mentioned. Why don't you want to use them? They're just packaged AutoIt scripts.

    If you really don't want to use someone else's exe files, you can create your own:

    http://www.autoitscript.com/site/autoit/


    Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)

    Friday, January 17, 2014 3:56 AM
  • For Windows 8.1 and WS2012R2 we have CmdLets:

    get-netadapter wi-fi |disable-netadapter

    get-netadapter wi-fi |enable-netadapter


    ¯\_(ツ)_/¯

    Friday, January 17, 2014 4:17 AM
  • By the way.  This only disables the WiFi networking and no other adapters.  "Airplane mode" means turn of the radio on the WiFi.


    ¯\_(ツ)_/¯

    Friday, January 17, 2014 4:18 AM
  • To use true Airplane mode you should also disable BlueTooth.

    ¯\_(ツ)_/¯

    Friday, January 17, 2014 4:20 AM
  • Disabling adapters stops certain network protocols from being used but, as jrv wrote, leaves the radio on.  Also, the network adapter for the Bluetooth Network  Bluetooth (RFCOMM Protocol TDI) isn't listed by the get-netadapter cmdlet but needs to be disabled to stop communications with it.
    Sunday, January 19, 2014 4:56 PM
  • Disabling adapters stops certain network protocols from being used but, as jrv wrote, leaves the radio on.  Also, the network adapter for the Bluetooth Network  Bluetooth (RFCOMM Protocol TDI) isn't listed by the get-netadapter cmdlet but needs to be disabled to stop communications with it.

    Actually I don't believe that is what is happening.  The "Airplane Mode" switch calls internal PIs and turns off all radios.  There is no equivalent in scripting.  Turning off or disabling an adapter shuts off the radio but is a much heavier approach.   You can also use WMI to turn off Bluetooth.

    Perhaps Microsoft will produce a commandline tool to toggle airplane mode.


    ¯\_(ツ)_/¯

    Sunday, January 19, 2014 5:36 PM
  • The easiest way to toggle airplane mode is to use <fn><F3>.

    Find the function key <fn> .  On most systems it is blue and in the left control group.  While holding <fn> press <F3> to toggle airplane mode.


    ¯\_(ツ)_/¯

    Sunday, January 19, 2014 5:44 PM
  • Thanks, jrv, for your knowledge and patience.

    I think the hardware switch invokes the setRadioState method of the IRadioInstance interface of the Windows Media Radio Management API to turn on or off the radio.  Is there a way to invoke that API from a script or do I need to write a small program to invoke the API.

    <fn><F3> lowers the volume on my laptop, a Vaio SVT15115CXS. There are no hardware buttons to change the state of the radio, which is why I'm looking for a way to change the state quickly.  <Windows>I->Change PC Settings->Network->Airplane Mode->Off is painful.

    I can transfer files over Bluetooth after executing the following.

    disable-netadapter -interfacedescription "Bluetooth Device (RFCOMM Protocol TDI)" -includehidden

    So, I'm still looking for a way to disable that adapter.

    Tuesday, January 21, 2014 3:41 AM
  • jrv, I just saw your post from 7/23/2012 regarding calling Windows APIs from Powershell.  Thanks again.
    Tuesday, January 21, 2014 4:01 AM
  • It's going to be trickier than that; this isn't a Win32 API function.  It's a COM interface, and I haven't found any documentation that would tell me how to do this in C++ yet, much less PowerShell (though that may be due to my own inexperience with COM.) If you can find a way to enumerate and bind to the existing IMediaRadioManager instances, the rest should fall into place.
    Tuesday, January 21, 2014 4:06 AM
  • It is all right here: http://code.msdn.microsoft.com/windowshardware/Radio-Manager-Sample-d6d3af91

    C++ and sample code.


    ¯\_(ツ)_/¯

    Tuesday, January 21, 2014 4:15 AM
  • I've looked through that. It appears to be sample code for implementing your own Radio Manager (for a new class / device), rather than for controlling other managers (for Bluetooth, etc.) All the information needed to write code to find and use existing radio managers might also be in there, but as I said, I don't have much experience with COM programming. There might be some standard way of finding instances of IMediaRadioManager using its GUID or information from the registry, I dunno.
    Tuesday, January 21, 2014 4:32 AM
  • Some more searching has turned up this link, where a Microsoft representative basically says "you can't do that" with public APIs: http://social.msdn.microsoft.com/Forums/en-US/e790991c-d093-49b0-a0cc-d30755d45ce0/about-the-way-to-turn-onoff-the-airplane-on-windows8?forum=wdk
    Tuesday, January 21, 2014 4:40 AM
  • If you read all of the docs you will find that there is no given API for controlling other radio managers.  You can query the system to find all radio instances and then set their state.  The docs show how to build a COM based solution for addressing radio instances.  The documentation is incomplete so we only have the preliminary code example.  This usually means building the samples and resolving the against the docs.

    I have an HP and an Acer which both have the keyboard shortcuts.  This is a hardware vendor spec so it will not exist on systems not designed for WI-Fi and Bluetooth.


    ¯\_(ツ)_/¯

    Tuesday, January 21, 2014 4:48 AM
  • I wonder if you can use an API monitor to figure out what Windows is doing in response to those hotkeys. I'll give it a shot on my Windows 8.1 laptop when I have some time.
    Tuesday, January 21, 2014 4:50 AM
  • Some more searching has turned up this link, where a Microsoft representative basically says "you can't do that" with public APIs: http://social.msdn.microsoft.com/Forums/en-US/e790991c-d093-49b0-a0cc-d30755d45ce0/about-the-way-to-turn-onoff-the-airplane-on-windows8?forum=wdk

    Yes - it can only be done with the DDK and only if you have the latest DDK and support agreements.  It is not published.  The DK sample will likely work if you have VS 2013 and the DDK.

    The article is a year old.  The newer DDK has been released and the API should be available.  It cannot be scripted without building a full COM object or  a utility.


    ¯\_(ツ)_/¯


    • Edited by jrv Tuesday, January 21, 2014 4:51 AM
    Tuesday, January 21, 2014 4:50 AM
  • I wonder if you can use an API monitor to figure out what Windows is doing in response to those hotkeys. I'll give it a shot on my Windows 8.1 laptop when I have some time.

    that is easy.  The function key (blue) calls the BIOS which sends a proprietary interrupt to the baseboard driver.  The baseboard driver has the vendors call to the vendors radio manager. It. happens at the kernel layer and cannot be synthesized.  Only Windows keys can be synthesized.  <fn> keys are hardware only.  A vendor sets the radio off in hardware and sends a message to the system.  The RM API discusses how the hardware has to send a message to toggle the "airplane mode" button.  The  action is performed in the hardware.


    ¯\_(ツ)_/¯

    Tuesday, January 21, 2014 4:56 AM
  • Remember this radio support exists only in Windows 8 and later and appears to only be fully implemented in Windows 8.1 and WS2012R2.  Of course the docs appear to be incomplete.

    ¯\_(ツ)_/¯

    Tuesday, January 21, 2014 4:57 AM