Have you ever wanted to have the functionality to be able to automatically remove an application from add/remove programs remotely? Well, now you can. With a combination of report writing and Task Server you can automate this process.
I have attached a zip file containing 2 files that get this to work. One is a report that provides a list of add/remove programs for a computer name that is entered, as well as providing a right-click option to uninstall the program. The other file is the Task Server script that executes the job. You simply need to import each xml file into the NS, one under reports and the other under the Task Server section.
dim uninstallcmd uninstallcmd = lcase(%!input2!%) if instr(uninstallcmd, "msiexec") > 0 then first=instr(uninstallcmd, "{") last=instr(uninstallcmd, "}") prodguid=mid(uninstallcmd, first, last) newcommand="msiexec.exe /uninstall " + prodguid + " /q" Set WshShell = WScript.CreateObject( "WScript.Shell" ) WshShell.Run newcommand else Set WshShell = WScript.CreateObject( "WScript.Shell" ) newcommand = chr(34)+uninstallcmd+chr(34) WshShell.Run newcommand end if
The first if statement is used when the installation program is an MSI. The second if statement accounts for all other types. For MSIs the uninstallation process can be done automatically because you can use the silent switch. For all other commands an extra step is needed on the client machine to finish the uninstall as there are no standard silent switches we can use.
Click to view.
SELECT T0.[Name] AS 'Name', T0.[Version] AS 'Version', replace(T0.[Uninstall Path],char(34),'') AS 'UninstallPath', T1.[_ResourceGuid] AS 'ResourceGuid' FROM [Inv_AeX_AC_Identification] T1 INNER JOIN [Inv_AeX_OS_Add_Remove_Programs] T0 ON T1.[_ResourceGuid] = T0.[_ResourceGuid] WHERE T1.[Name] LIKE %entername%
Where %entername% is the machine name from a parameter in the report.
Now here is the special part. You need to define a drill down for the report. The drill down fields should be as follows: Drill down to: Another web page Name: Remove Application (or whatever you want to put here) URL: http://{NS_NAME}/Altiris/TaskManagement/taskaccess.aspx Query string: taskAccessRequestType=startTask&taskAccessTaskGuid=30ffa10c-7c08-4b95 -b428-6a466426d15d&taskAccessInstancename=&INPUT2="%UninstallPath%" &@AssignedResources=%ResourceGuid% The GUID right after "taskAccessTaskGuid=" refers to the GUID of the script task that you created earlier.
... and you're done.
The VB script grabs only what is needed from the uninstall path and places the proper MSIEXEC command to run the uninstall command.
newcommand="msiexec.exe /uninstall " + "{BA3C8C28-C096-450B-B78C-5EA939A073D4}" + " /q"Set WshShell = WScript.CreateObject( "WScript.Shell" )WshShell.Run newcommand
use Altirisselect _ResourceGuid fromdbo.Inv_AeX_OS_Add_Remove_Programswhere Name = 'Trinket'
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://localhost/Altiris/TaskManagement/taskaccess.aspx?taskAccessRequestType=startTask&taskAccessTaskGuid=30ffa10c-7c08-4b95-b428-6a466426d15d&taskAccessInstancename=&INPUT2="%DS:UninstallPath%"&@AssignedResources=%DS:ResourceGuid%"
taskAccessRequestType=startTask&taskAccessTaskGuid=cc2a1a49-5d04-429e-8d39-5c7dd97d4482&taskAccessInstancename=&INPUT2="%UninstallPath%"&@AssignedResources=%ResourceGuid%