def addProfile(strPath): ''' adds a profile to the saved configurations. Configuration has to be an exported .xml file ''' strCorrPath = os.path.normpath(strPath) strCmd = 'netsh wlan add profile filename="' + strCorrPath + '"' executeNonQuery(strCmd)
def setConnectionMode(strProfile, setToAuto=True): ''' updates the connection mode of the specified profile ''' strMode = "auto" if setToAuto else "manual" strCmd = 'netsh wlan set profileparameter name="' + strProfile + '" connectionmode=' + strMode executeNonQuery(strCmd)
def exportProfile(strProfile, strPath, clearKey=True): ''' exports a profile to a xml-file ''' strKey = "key=clear " if clearKey else "" strCorrPath = os.path.normpath(strPath) strCmd = 'netsh wlan export profile name="' + strProfile + '" ' + strKey + 'folder="' + strCorrPath + '"' executeNonQuery(strCmd)
def enableInterface(strInterface, setEnabled=True): ''' enables or disables specified interface ''' if not isAdmin(): raise NotAdminException() else: strEnabled = "ENABLED" if setEnabled else "DISABLED" strCmd = 'netsh interface set interface name="' + strInterface + '" admin=' + strEnabled executeNonQuery(strCmd)
def disconnect(): ''' shuts down the WLAN-Connection ''' executeNonQuery("netsh wlan disconnect")
def deleteProfile(strProfile): ''' CAREFULL!!!! This function permanently deletes a profile ''' strCmd = 'netsh wlan delete profile name="' + strProfile + '"' executeNonQuery(strCmd)
def connectTo(strProfile): ''' tries to establish a WLAN-Connection to the specified Profile ''' executeNonQuery("netsh wlan connect " + strProfile)