Uninstalling the device agent from a Mac Device

Use this procedure to uninstall the SOTI MobiControl Mac Agent from a Mac machine.

About this task

To uninstall the SOTI MobiControl Mac Agent manually, do the following:

Procedure

  1. Copy and paste the following code to a file named MCUninstaller.sh:
    #!/bin/sh
    
    PKGNAME=AgentUninstaller
    LOG=/tmp/$PKGNAME.log
    touch $LOG
    chmod a+rw $LOG
    
    DAEMON_PLIST="/Library/LaunchDaemons/net.soti.mobicontrol.macOSHelper.plist"
    DAEMON_CAPTURE_PLIST="/Library/LaunchDaemons/net.soti.mobicontrol.sotiCapture.plist"
    AGENT_PLIST="/Library/LaunchAgents/net.soti.mobicontrol.macOS.plist"
    
    WriteLog ()
    {
        /bin/echo `date`" "$1 >> $LOG
    }
    
    WriteLog "Local user is $LOCAL_USER"
    
    WriteLog "Modifying launchd plists"
    /usr/libexec/PlistBuddy -c "Delete :KeepAlive" $DAEMON_PLIST
    /usr/libexec/PlistBuddy -c "Delete :KeepAlive" $DAEMON_CAPTURE_PLIST
    /usr/libexec/PlistBuddy -c "Delete :KeepAlive" $AGENT_PLIST
    
    WriteLog "Unloading the plists"
    
    /bin/launchctl unload $DAEMON_PLIST
    /bin/launchctl unload $DAEMON_CAPTURE_PLIST
    /bin/launchctl unload $AGENT_PLIST
    
    WriteLog "Removing plists"
    /bin/rm $DAEMON_PLIST
    /bin/rm $DAEMON_CAPTURE_PLIST
    /bin/rm $AGENT_PLIST
    
    WriteLog "Removing MobiControl folder except recovery key file"
    cd "/Library/Application Support"
    rm -rf "MobiControl_Resources"
    rm -rf "MobiControl"
    rm -rf "MC.log"
    
    
    shopt -s extglob
    if [ -d "/Library/Application Support/MobiControl" ]; then
        cd "/Library/Application Support/MobiControl"
        rm -rf !(FDE.plist|settings|encKeys)
    fi
    
    WriteLog "Removing agent and helper binaries"
    rm -rf "/Users/$LOCAL_USER/Applications/MobiControl.app/"
    rm -rf "/Applications/MobiControl.app/"
    rm -rf "/Library/PrivilegedHelperTools/net.soti.mobicontrol.macOSHelper"
    rm -rf "/Library/PrivilegedHelperTools/net.soti.mobicontrol.sotiCapture"
    rm -rf "/Library/Application Support/pdb.ini"
    
    pidMobiControl=`pgrep -x "MobiControl"`
    WriteLog "MobiControl PID is $pidMobiControl"
    
    kill -9 $pidMobiControl
    
    
    WriteLog "Unistall complete"
    
    echo "Mac Agent Un-installed Successfully"
  2. Save the file to the Mac machine desktop.
  3. Open the terminal app and type:
    sudo su [give the Administrator password]
    /Users/username/Desktop/MCUninstaller.sh [replace username with the Mac machine username]
  4. Run the script.
  5. On successful un-install of the Mac Agent, the following message displays: "Mac Agent Un-installed Successfully".