-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomAction.cs
More file actions
42 lines (38 loc) · 1.66 KB
/
CustomAction.cs
File metadata and controls
42 lines (38 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
}
}
}