use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set the_password to "test"
set the_command_list to {¬
"networksetup -setnetworkserviceenabled Wi-Fi off", ¬
"networksetup -setairportpower Wi-Fi off", ¬
"rm /Library/Preferences/com.apple.wifi.known-networks.plist", ¬
"rm /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist", ¬
"rm /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist.backup", ¬
"rm /Library/Preferences/SystemConfiguration/com.apple.network.identification.plist", ¬
"rm /Library/Preferences/SystemConfiguration/com.apple.network.eapolclient.configuration.plist", ¬
"rm /Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist", ¬
"rm /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist", ¬
"rm /Library/Preferences/SystemConfiguration/preferences.plist"}
repeat with the_command in the_command_list
try
do shell script the_command password the_password with administrator privileges
display dialog the_command & return & return & "was executed" giving up after 20
on error errortext
display dialog the_command & return & return & "returned: " & return & errortext with icon 2 giving up after 20
end try
end repeat
display dialog "Restart the computer and turn Wifi / WLAN back on"