Procedure to run Comodo Patch Agent Silent Installer/Uninstaller

Here are two procedures for Comodo Patch Agent, one is the silent installer and on the silent uninstaller.



Requirements for procedures:

Download the Patch Management Agent from your Comodo ITSM Patch Management console. Copy the agent command line as you will replace the one in the template with the one you get. They are site specific so each of your sites will need a separate one or they will all show under the same client. The installer can be used on multiple computers at the same site.

Change the path and the command to match your Patch Management Agent path and the copied command.



Notes:

I found running the procedure as system user rather than logged in user gave more consistent results.

I also found that while the /qn switch worked most of the time, every now and then it would give me an Even Log error that it needs to be run as Administrator. I have not had that happen after trying it with /qr and the UI still does not shown for the user so your choice.

EDIT:

I changed the print message as I found that failed installs were only passing the letter T as the error. Also failed installs due to bad paths were not triggering Comodo log to show as failures so you had to read each log and see if the logs showed a T or not. I added an undeclared variable that runs only if the install failed and thus triggers Comodo log to show it as a failure.


Procedure to install Comodo Patch Management Agent:

MAKE SURE YOU CHANGE THE PATH TO FIT YOUR ENVIRONMENT


import subprocess;

# Change driveletter and path to the location your msi is stored. The path \  may need to be doubled. Example c:	est	est	est.msi becomes c:\	est\	est\	est.msi.
# I have had the single \ work but also fail while I have not had the \\ fail.
# Change the words agent command line to the corresponding keys you copied from the Comodo Patch Management Agent download link

process=subprocess.Popen(["msiexec.exe", "/i", "driveletter:\\path\\patch_agent.msi", "/qr", "AGENTUSERNAME=agent command line",
                          "PASSWORD=agent command line", "CUSTOMER=agent command line", "IPADDRESS=agent command line"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)

result=process.communicate()[0]
if result == "":
    print "Install successful!"
else:
    print "Install failed. Please check your file actually exists and is accessible in the path you specified."
    print err

Procedure to uninstall Comodo Patch Management Agent:

MAKE SURE YOU CHANGE THE PATH TO FIT YOUR ENVIRONMENT


import subprocess;

# Change driveletter and path to the location your msi is stored. The path \ may need to be doubled. Example c:	est	est	est.msi becomes c:\	est\	est\	est.msi.
# I have had the single \ work but also fail while I have not had the \\ fail.

process=subprocess.Popen(["msiexec.exe", "/x", "driveletter:\\path\\patch_agent.msi", "/qr"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)

result=process.communicate()[0]
if result == "":
    print "Install successful!"
else:
    print "Install failed. Please check your file actually exists and is accessible in the path you specified."
    print err