|
using System;
using Microsoft.Deployment.WindowsInstaller;
namespace ClosePromptCA
{
public class CustomActions
{
[CustomAction]
public static ActionResult ClosePrompt(Session session)
{
session.Log("Begin PromptToCloseApplications");
try
{
var productName = session["ProductName"];
var processes = session["PromptToCloseProcesses"].Split(',');
var displayNames = session["PromptToCloseDisplayNames"].Split(',');
if (processes.Length != displayNames.Length)
{
session.Log(@"Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items.");
return ActionResult.Failure;
}
for (var i = 0; i < processes.Length; i++)
{
session.Log("Prompting process {0} with name {1} to close.", processes[i], displayNames[i]);
using (var prompt = new PromptCloseApplication(productName, processes[i], displayNames[i]))
if (!prompt.Prompt())
return ActionResult.Failure;
}
}
catch(Exception ex)
{
session.Log("Missing properties or wrong values. Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items. \nException:" + ex.Message);
return ActionResult.Failure;
}
session.Log("End PromptToCloseApplications");
return ActionResult.Success;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
10+ years of software design and development.
Using C/C++, C#, JavaScript, Java, Python, AngularJS, React, React Native, .NET, WinAPI, WPF, PureMVC, MVVM, MVC, Unix/Linux, AWS, Azure, Heroku, Git, grafana, InfluxDB, TeamCity, Jenkins, Gulp, MS SQL, PostgreSQL, MySQL, Snowflake SQL, MongoDB
http://ileonenko.wordpress.com