Deinstallation of OEM Agent from Windows

This posts narrates how we can deinstall OEM agent from Windows.

First, stop the agent

cd D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\bin>
emctl stop agent

Next, deinstall the agent

D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl\bin\perl  D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl -agentHome  D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0

Here, D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0 is the agent home.

Output from the above command

D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install>D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl\bin\perl D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl -agentHome D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\

Agent Oracle Home: D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0

agentHome = D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0

NOTE: The agent base directory: D:/Oralce_OEM_12c_Agent will be removed after successful deinstallation of agent home.

DetachHome Command executed:D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\oui\bin\setup.exe -detachHome -force -depHomesOnly -silent ORACLE_HOME=D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0 -waitForCompletion -invPtrLoc D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\oraInst.loc

Deinstall Command executed:D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\oui\bin\setup.exe -deinstall -silent "REMOVE_HOMES={D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0}" -waitForCompletion -removeAllFiles -invPtrLoc D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\oraInst.loc
cannot unlink file for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl\bin\perl.exe: Permission denied at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot unlink file for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl\bin\perl510.dll: Permission denied at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl\bin: Directory not empty at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\perl: Directory not empty at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install: Permission denied at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman: Directory not empty at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0: Directory not empty at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303
cannot remove directory for D:\Oralce_OEM_12c_Agent\core: Directory not empty at D:\Oralce_OEM_12c_Agent\core\12.1.0.4.0\sysman\install\AgentDeinstall.pl line 303

NOTE: The targets monitored by this Management Agent will not be deleted in the Enterprise Manager Repository by this deinstall script. Make sure to delete the targets manually from the Cloud Control Console for a successful deinstallation.

Check the monitoring target details from OMS server

$ sqlplus sysman/password

set line 188
col target_name for a38
col TARGET_TYPE for a15
col TIMEZONE_REGION for a16
col DISPLAY_NAME for a38
col HOST_NAME for a33
col owner for a15

SQL> SELECT target_name, target_type, timezone_region, owner, host_name, is_active
2   FROM mgmt_targets 
3   WHERE lower (host_name) LIKE '%agent_box%';

TARGET_NAME               TARGET_TYPE     TIMEZONE_REGION     OWNER           HOST_NAME                 IS_ACTIVE
------------------------- --------------- ------------------- --------------- ------------------------- ------------
agent_box.abc.com         host            America/Chicago     SYSMAN          agent_box.abc.com          1
agent_box.abc.com:3872    oracle_emd      America/Chicago     SYSMAN          agent_box.abc.com          1

Delete the targets from OMS configuration

cd $OMS_HOME/bin
./emcli login -username=sysman 
./emcli delete_target -name="agent_box.abc.com:3872" -type="oracle_emd" -delete_monitored_targets 
Target "agent_box.abc.com:3872:oracle_emd" deleted successfully
sqlplus sysman/password

SELECT target_name, target_type, timezone_region, owner, host_name, is_active
FROM mgmt_targets 
WHERE lower (host_name) LIKE '%agent_box%';

no rows selected

Manually delete the agent base directory

del D:\Oralce_OEM_12c_Agent

Delete the services

D:\Oralce_OEM_12c_Agent>sc delete Oracleagent12c1Agent

Delete registry entries

Computer -> HKEY_LOCAL_MACHINE -> SOFTWARE -> ORACLE -> KEY_agent12c1
Computer -> HKEY_LOCAL_MACHINE -> SOFTWARE -> ORACLE -> KEY_sbin12c1
Computer -> HKEY_LOCAL_MACHINE -> SOFTWARE -> ORACLE -> SYSMAN -> Oracleagent12c1Agent
Computer -> HKEY_LOCAL_MACHINE -> SOFTWARE -> ORACLE -> SYSMAN -> OracleAgent12cR4 (This is Management Agent service)
Computer -> HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> services -> Oracleagent12c1Agent (This is Management Agent key)
Computer -> HKEY_LOCAL_MACHINE -> SYSTEM -> ControlSet002 -> services -> (No Management Agent service here)

Deletion of agent from Windows host is complete

Hope this helps ...

Comments