Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RemoteApplicationPublisher/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Runtime.Versioning;
using System.Windows.Forms;

namespace RemoteApplicationPublisher
{
[SupportedOSPlatform("windows")]
internal static class Program
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions RemoteApplicationPublisher/RemoteAppEditWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 54 additions & 32 deletions RemoteApplicationPublisher/RemoteAppEditWindow.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

using System;
using System.IO;
using System.Runtime.Versioning;
using System.Windows.Forms;
using Microsoft.Win32;

namespace RemoteApplicationPublisher
{

[SupportedOSPlatform("windows")]
public partial class RemoteAppEditWindow : Form
{

Expand All @@ -29,7 +31,7 @@ public RemoteAppEditWindow(RemoteAppMainWindow mainWindow)
public RemoteApp EditRemoteApp(RemoteApp selectedRemoteApp)
{
HelpSystem.SetupTips(this);
RemoteApp = selectedRemoteApp;
RemoteApp = selectedRemoteApp ?? new RemoteApp();
Text = "Properties of " + RemoteApp.Name;
Size = MinimumSize;
HelpSystem.SetupTips(this);
Expand Down Expand Up @@ -91,8 +93,16 @@ public void LoadValues()
break;
}
checkBoxOILauncher.Checked = RemoteApp.UseLauncher;
checkBoxDebug.Enabled = checkBoxOILauncher.Checked;

checkBoxDebug.Checked = CommandLineText.Text.Contains(enableDebug);
if (checkBoxOILauncher.Checked)
{
checkBoxDebug.Checked = CommandLineText.Text.Contains(enableDebug);
}
else
{
checkBoxDebug.Checked = false;
}

Icon = RemoteAppFunction.ReturnIcon(RemoteApp.Path);
}
Expand Down Expand Up @@ -139,13 +149,14 @@ private bool DoBrowsePath()

private void SaveRemoteApp(string ShortName, string FullName, string Path, string VPath, string CommandLine, int CommandLineSetting, string IconPath, int IconIndex, int ShowInTSWA)
{

var SysApps = new SystemRemoteApps();

if (RemoteApp.Name is not null & !(Text == "New RemoteApp"))
{
if (!((RemoteApp.Name ?? "") == (ShortName ?? "")))
if (RemoteApp.Name != null && ShortName != null && !((RemoteApp.Name ?? "") == (ShortName ?? "")))
#pragma warning disable 8604
SysApps.RenameApp(RemoteApp.Name, ShortName);
#pragma warning restore 8604
}

RemoteApp.Name = ShortName;
Expand Down Expand Up @@ -186,19 +197,22 @@ private void SaveButton_Click(object sender, EventArgs e)

private void SaveAndEditWindow()
{
if (string.IsNullOrEmpty(ShortNameText.Text))
if (string.IsNullOrEmpty(ShortNameText?.Text))
{
MessageBox.Show("Name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(FullNameText.Text))
else if (string.IsNullOrEmpty(FullNameText?.Text))
{
MessageBox.Show("Full name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(PathText.Text))
else if (string.IsNullOrEmpty(PathText?.Text))
{
MessageBox.Show("Path must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
// Already checked for null or empty.
#pragma warning disable 8604
else if (!((ShortNameText.Text ?? "") == (RemoteApp.Name ?? "")) & DoesAppExist(ShortNameText.Text))
#pragma warning restore 8604
{
MessageBox.Show("A RemoteApp with the same name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
Expand Down Expand Up @@ -226,12 +240,12 @@ private int GetCommandLineOption()

private void SaveAndCloseOrWindow()
{
if (string.IsNullOrEmpty(ShortNameText.Text))
if (string.IsNullOrEmpty(ShortNameText?.Text))
{
MessageBox.Show("Name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ShowDialog();
}
else if (string.IsNullOrEmpty(FullNameText.Text))
else if (string.IsNullOrEmpty(FullNameText?.Text))
{
MessageBox.Show("Full name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ShowDialog();
Expand All @@ -241,7 +255,10 @@ private void SaveAndCloseOrWindow()
MessageBox.Show("Path must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ShowDialog();
}
// Already checked for null.
#pragma warning disable 8604
else if (!((ShortNameText.Text ?? "") == (RemoteApp.Name ?? "")) & DoesAppExist(ShortNameText.Text))
#pragma warning restore 8604
{
MessageBox.Show("A RemoteApp with the same name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
ShowDialog();
Expand All @@ -260,19 +277,22 @@ private void SaveAndCloseOrWindow()

private void SaveAndClose()
{
if (string.IsNullOrEmpty(ShortNameText.Text))
if (string.IsNullOrEmpty(ShortNameText?.Text))
{
MessageBox.Show("Name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(FullNameText.Text))
else if (string.IsNullOrEmpty(FullNameText?.Text))
{
MessageBox.Show("Full name must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else if (string.IsNullOrEmpty(PathText.Text))
else if (string.IsNullOrEmpty(PathText?.Text))
{
MessageBox.Show("Path must not be blank.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
// Already checked for null.
#pragma warning disable 8604
else if (!((ShortNameText.Text ?? "") == (RemoteApp.Name ?? "")) & DoesAppExist(ShortNameText.Text))
#pragma warning restore 8604
{
MessageBox.Show("A RemoteApp with the same name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
Expand All @@ -294,29 +314,31 @@ private void ShortNameText_TextChanged(object sender, EventArgs e)

private void checkBoxOILauncher_CheckedChanged(object sender, EventArgs e)
{
if (!populatingEditDialog)
{
if (checkBoxOILauncher.Checked)
{
RemoteAppOriginalPath = PathText.Text;
PathText.Text = remoteLauncher;
radioButtonEnforced.Checked = true;
CommandLineText.Text = string.Format(commandLineTemplate, RemoteAppOriginalPath);
}
else
{
var sra = new SystemRemoteApps();
var currentApp = sra.GetApp(ShortNameText.Text);
if (currentApp != null)
{
RemoteAppOriginalPath = currentApp.VPath;
}
PathText.Text = RemoteAppOriginalPath;
radioButtonOptional.Checked = true;
CommandLineText.Text = string.Empty;
if (!populatingEditDialog)
{
if (checkBoxOILauncher.Checked)
{
RemoteAppOriginalPath = PathText.Text;
PathText.Text = remoteLauncher;
radioButtonEnforced.Checked = true;
CommandLineText.Text = string.Format(commandLineTemplate, RemoteAppOriginalPath);
}
else
{
var sra = new SystemRemoteApps();
var currentApp = sra.GetApp(ShortNameText.Text);
if (currentApp != null)
{
RemoteAppOriginalPath = currentApp.VPath;
}
PathText.Text = RemoteAppOriginalPath;
radioButtonOptional.Checked = true;
checkBoxDebug.Checked = false;
CommandLineText.Text = string.Empty;
}
}

checkBoxDebug.Enabled = checkBoxOILauncher.Checked;
PathText.Enabled = !checkBoxOILauncher.Checked;
BrowsePath.Enabled = !checkBoxOILauncher.Checked;
panelOptions.Enabled = !checkBoxOILauncher.Checked;
Expand Down
4 changes: 2 additions & 2 deletions RemoteApplicationPublisher/RemoteAppEditWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA1iMAAAJNU0Z0AUkBTAIBAQkB
AAGAAQIBgAECARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAATADAAEBAQABIAYAATD/
AAGIAQIBiAECARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAATADAAEBAQABIAYAATD/
AB8AAysBQQMGAQgYAAMGAQgDKwFB1AADKwFBATMBMAHyAf8CQAGyAf0DBgEIEAADBgEIAisBfgH8ARUB
EwHqAf8DKwFBzAADKwFBATwBOgH1Af8BRwFFAfoB/wE8ATkB9gH/AisBfgH8AwYBCAgAAwYBCAIrAX4B
/AElASMB8QH/ATABLgH2Af8BFQETAeoB/wMrAUHIAAMeASsBPwE8AfYB/wFJAUYB+gH/AVUBVAL/AT0B
Expand All @@ -75,7 +75,7 @@
/wFSAVAC/wE7ATkB9wH/ASMBIQHuAf8DHgEr3AADHgErAUEBPwH3Af8BXQFaAv8BPQE6Av8BOwE4Av8B
VgFUAv8BLAEqAfAB/wMeASvgAAMGAQgCQAG1Af0BYQFdAv8BQgE/Av8BPwE8Av8BWgFYAv8CQAGzAf0D
BgEI3AADBgEIAisBfgH8AVQBUQH7Af8BgAFiAv8BYgFfAv8BYAFdAv8BXQFbAv8BQgFAAfcB/wIrAX4B
/AMGAQjUAAMGAQgBNQEvAX4B/AFbAVgB/QH/AYYBggL/AVoBVwH8Af8BSAFGAfgB/wFEAUEB9wH/AVEB
/AMGAQjUAAMGAQgBNAEuAX4B/AFbAVgB/QH/AYYBggL/AVoBVwH8Af8BSAFGAfgB/wFEAUEB9wH/AVEB
TgH6Af8BXwFdAv8BRAFBAfcB/wIrAX4B/AMGAQjMAAMGAQgCQAG4Af0BYQFeAf4B/wGKAYcC/wFgAV0B
/QH/AVABTQH7Af8DHgErAx4BKwFFAUIB+AH/AVIBUAH6Af8BYQFeAv8BRQFDAfcB/wIrAX4B/AMEAQXI
AAMXAR8BXgFbAv8BgQFiAv8BgQFiAf4B/wFYAVUB/QH/Ax4BKwgAAx4BKwFGAUMB+AH/AVMBUQH7Af8B
Expand Down
2 changes: 2 additions & 0 deletions RemoteApplicationPublisher/RemoteAppFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Microsoft.Win32;

namespace RemoteApplicationPublisher
{

[SupportedOSPlatform("windows")]
static class RemoteAppFunction
{

Expand Down
9 changes: 9 additions & 0 deletions RemoteApplicationPublisher/RemoteAppHostOptions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Runtime.Versioning;
using System.Windows.Forms;
using Microsoft.Win32;

namespace RemoteApplicationPublisher
{
[SupportedOSPlatform("windows")]
public partial class RemoteAppHostOptions : Form
{
private RemoteAppMainWindow _mainWindow;
Expand Down Expand Up @@ -139,7 +141,10 @@ public void SetValues()
TimeoutIdleCheckBox.Checked = false;
}

// Code has a default value.
#pragma warning disable 8605
var fResetBroken = ((Int32)PolicyKey.GetValue("fResetBroken", 0)) == 0 ? false : true;
#pragma warning restore 8605
if (fResetBroken != default)
{
LogoffWhenTimoutCheckBox.Checked = true;
Expand All @@ -149,7 +154,11 @@ public void SetValues()
LogoffWhenTimoutCheckBox.Checked = false;
}

// Code has a default value.
#pragma warning disable 8605
var fAllowUnlistedRemotePrograms = ((Int32)PolicyKey.GetValue("fAllowUnlistedRemotePrograms", 0)) == 0 ? false : true;
// Code has a default value.
#pragma warning restore 8605
if (fAllowUnlistedRemotePrograms != default)
{
AllowUnlistedRemoteProgramsCheckBox.Checked = true;
Expand Down
8 changes: 5 additions & 3 deletions RemoteApplicationPublisher/RemoteAppLib.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

using System;
using System.Runtime.Versioning;
using Microsoft.Win32;

namespace RemoteApplicationPublisher
Expand Down Expand Up @@ -33,6 +34,7 @@ public class RemoteApp
public bool UseLauncher = false;
}

[SupportedOSPlatform("windows")]
public class SystemRemoteApps
{
private string RegistryPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList\Applications";
Expand All @@ -49,9 +51,9 @@ public void Init()
{
string RegistryPathCV = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\";
var cvKey = Registry.LocalMachine.OpenSubKey(RegistryPathCV, true);
var tsKey = cvKey.CreateSubKey("Terminal Server");
var tsaaKey = tsKey.CreateSubKey("TSAppAllowList");
var appKey = tsaaKey.CreateSubKey("Applications");
var tsKey = cvKey?.CreateSubKey("Terminal Server");
var tsaaKey = tsKey?.CreateSubKey("TSAppAllowList");
var appKey = tsaaKey?.CreateSubKey("Applications");
}

public RemoteAppCollection GetAll()
Expand Down
4 changes: 3 additions & 1 deletion RemoteApplicationPublisher/RemoteAppMainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.Versioning;
using System.Windows.Forms;

namespace RemoteApplicationPublisher
{
[SupportedOSPlatform("windows")]
public partial class RemoteAppMainWindow : Form
{
private string clipboardText = string.Empty;
Expand Down Expand Up @@ -210,7 +212,7 @@ private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)

private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
if (AppList.FocusedItem != null)
if (AppList.FocusedItem != null && !string.IsNullOrEmpty(clipboardText))
{
Clipboard.SetText(clipboardText);
}
Expand Down