Folder Delete After Uninstall

Thanks for the reply. I think we have this working now. We split it up and have one for 64-bit PCs and one for 32-bit. It will uninstall Sophos and also delete’s the “Sophos” folder from Program Files (x86) and Program Files. Below is the 64-bit action script:

//SophosStopServices
waithidden net stop "Sophos Anti-Virus"
waithidden net stop "Sophos AutoUpdate Service"
waithidden net stop "Sophos Agent"
waithidden net stop "Sophos Anti-Virus status reporter"
waithidden net stop "Sophos Message Router"
waithidden net stop "Sophos Network Threat Protection"
waithidden net stop "Sophos System Protection Service"
waithidden net stop "Sophos Web Control Service"
waithidden net stop "Sophos Web Intelligence Service"
waithidden net stop “Sophos Web Intelligence Update”

//Endpoint Defense
dos echo "Endpoint Defense"
if {exists folder “C:\Program Files\Sophos\Endpoint Defense”}
waithidden C:\Program Files\Sophos\Endpoint Defense\uninstall.exe /quiet
endif

//System Protection
dos echo "System Protection"
if {exists folder “C:\Program Files (x86)\Sophos\Sophos System Protection”}
waithidden MsiExec.exe /X{{1093B57D-A613-47F3-90CF-0FD5C5DCFFE6} /quiet /norestart
endif

//AutoUpdate
dos echo "AutoUpdate"
if {exists folder “C:\Program Files (x86)\Sophos\AutoUpdate”}
waithidden MsiExec.exe /X{{AFBCA1B9-496C-4AE6-98AE-3EA1CFF65C54} /quiet /norestart
endif

//RemoteManagement
dos echo "Remote Management"
if {exists folder “C:\Program Files (x86)\Sophos\Remote Management System”}
waithidden MsiExec.exe /X{{FED1005D-CBC8-45D5-A288-FFC7BB304121} /quiet /norestart
endif

//Anti Virus
dos echo "Anti Virus"
if {exists folder “C:\Program Files (x86)\Sophos\Sophos Anti-Virus”}
waithidden MsiExec.exe /X{{65323B2D-83D4-470D-A209-D769DB30BBDB} /quiet /norestart
endif

//Network Threat
dos echo "Network Threat"
if {exists folder “C:\Program Files\Sophos\Sophos Network Threat Protection”}
waithidden MsiExec.exe /X{{66967E5F-43E8-4402-87A4-04685EE5C2CB} /quiet /norestart
endif

//Delete Sophos Directory
waithidden CMD.EXE /C rmdir /Q /S "C:\Program Files (x86)\Sophos"
waithidden CMD.EXE /C rmdir /Q /S “C:\Program Files\Sophos”

If your curious about relevance, let me know. Hopefully this will help you too.

If that’s the “64 bit” script then it will mostly work on the “32 bit” paths as C:\Program Files becomes C:\Program Files (x86) on the agent as mentioned before.

Another issue that can happen is if you call installers then they can spawn other tasks and the original program returns. We do have an override to wait for the entire process tree to complete as well especially if you are trying to delete the files afterward as they still may be executing.

Sorry, I’m very new to this and I don’t think i’m following you. When your talking about the original program returning, this is because the installer hasn’t completed yet?

When msiexec is called it can spawn a separate program and then “complete” so while there is a process under that tree, the original program completed and the actionscript will move on.

See https://developer.bigfix.com/action-script/reference/execution/override.html and the Completion keyword