Solution 1 : SendKeys
AFAIK the Fn key on a keyboard is not intercepted by Windows, it is a hardware mapping to a function key ie. "Volume Up".
Now the problem with that is that the "shutdown/enable wifi" key sends a signal to the hardware to power off the card.
So that's that for the SendKey, there is no virtual key for "Wireless off/on" (although there is one for "volume up").
Solution 2 : The Windows 8 API
Now the other approach would be to use the Windows 8 API here https://msdn.microsoft.com/en-us/library/windows/hardware/hh406627(v=vs.85).aspx and more specifically the following interfaces :
- IMediaRadioManager
- IRadioInstance
- IRadioInstanceCollection
- IMediaRadioManagerNotifySink
This should allow you to get the radio for bluetooth, wifi, ... as well as the "airplane mode" then shut them down, but I've never tried to use that with VBS.
Solution 3 : Using WMI queries
Using WMI queries you can basically access anything in your machine, including network cards.
The class you are looking for is "Win32_NetworkAdapter" and all docs can be found here : https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx
Here is a little sample code that will list the current network adapters, you can customize this to save which ones were enabled before you run the script to be able to re enable them after.
' connects to the WMI server of the local machine
Set objConnection = GetObject("winmgmts:" _
& "{impersonationLevel=Delegate," _
& "authenticationLevel=PktPrivacy}!" _
& "\\localhost\root\cimv2")
' gets a list of all the network adapters in the system
Set objNetworkAdapters = objConnection.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
' loops through all network adapters
For Each objCurrentNetworkAdapter in objNetworkAdapters
' objCurrentNetworkAdapter.Disable
' objCurrentNetworkAdapter.Enable
WScript.Echo objCurrentNetworkAdapter.Name
Next
Remark :
You are basically not supposed to access the "Airplane mode" from code as it is a user privilege to do so, imagine if someone builds an app that turns on roaming and data connection then starts updating while you are abroad...