mirror of
https://github.com/kimmknight/remoteapptool.git
synced 2025-08-09 20:24:05 +00:00
Initial commit
This commit is contained in:
2
remoteapplib/.gitignore
vendored
Normal file
2
remoteapplib/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
bin/
|
||||
obj/
|
6
remoteapplib/App.config
Normal file
6
remoteapplib/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
</startup>
|
||||
</configuration>
|
34
remoteapplib/My Project/AssemblyInfo.vb
Normal file
34
remoteapplib/My Project/AssemblyInfo.vb
Normal file
@@ -0,0 +1,34 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2016")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("936d6a70-fabd-4205-a2bb-4232560e468a")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.1")>
|
183
remoteapplib/RemoteAppLib.vb
Normal file
183
remoteapplib/RemoteAppLib.vb
Normal file
@@ -0,0 +1,183 @@
|
||||
Imports System.Reflection.Assembly
|
||||
|
||||
Public Class RemoteAppCollection
|
||||
Inherits System.Collections.CollectionBase
|
||||
|
||||
Public Sub Add(RemoteApp As RemoteApp)
|
||||
List.Add(RemoteApp)
|
||||
End Sub
|
||||
|
||||
Public Sub Remove(RemoteApp As RemoteApp)
|
||||
List.Remove(RemoteApp)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class RemoteApp
|
||||
|
||||
Public Name As String
|
||||
Public FullName As String
|
||||
Public Path As String
|
||||
Public VPath As String
|
||||
Public IconPath As String
|
||||
Public IconIndex As Integer = 0
|
||||
Public CommandLine As String = ""
|
||||
Public CommandLineOption As Integer = 1
|
||||
Public TSWA As Boolean = False
|
||||
Public FileTypeAssociations As FileTypeAssociationCollection
|
||||
|
||||
End Class
|
||||
|
||||
Public Class FileTypeAssociation
|
||||
Public Extension As String
|
||||
Public IconPath As String
|
||||
Public IconIndex As String
|
||||
End Class
|
||||
|
||||
Public Class FileTypeAssociationCollection
|
||||
Inherits System.Collections.CollectionBase
|
||||
|
||||
Public Sub Add(FileTypeAssociation As FileTypeAssociation)
|
||||
List.Add(FileTypeAssociation)
|
||||
End Sub
|
||||
|
||||
Public Sub Remove(FileTypeAssociation As FileTypeAssociation)
|
||||
List.Remove(FileTypeAssociation)
|
||||
End Sub
|
||||
|
||||
Public Function GetFlatFileTypes() As String
|
||||
GetFlatFileTypes = ""
|
||||
If List.Count > 0 Then
|
||||
For Each listItem As FileTypeAssociation In List
|
||||
GetFlatFileTypes += ",." & listItem.Extension
|
||||
Next
|
||||
GetFlatFileTypes = GetFlatFileTypes.Substring(1)
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Class IconSelection
|
||||
Public IconPath As String
|
||||
Public IconIndex As String
|
||||
End Class
|
||||
|
||||
|
||||
Public Class SystemRemoteApps
|
||||
Private Legacy32bit As Boolean = False
|
||||
Private RegistryPath As String = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList\Applications"
|
||||
Private BaseKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(RegistryPath)
|
||||
Private BaseKeyWrite As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(RegistryPath, True)
|
||||
|
||||
Public Sub Init()
|
||||
Dim RegistryPathCV As String = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
|
||||
Dim cvKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(RegistryPathCV, True)
|
||||
Dim tsKey As Microsoft.Win32.RegistryKey = cvKey.CreateSubKey("Terminal Server")
|
||||
Dim tsaaKey As Microsoft.Win32.RegistryKey = tsKey.CreateSubKey("TSAppAllowList")
|
||||
Dim appKey As Microsoft.Win32.RegistryKey = tsaaKey.CreateSubKey("Applications")
|
||||
End Sub
|
||||
|
||||
Public Function GetAll() As RemoteAppCollection
|
||||
|
||||
Dim SystemAppCollection As New RemoteAppCollection
|
||||
|
||||
For Each App As String In BaseKey.GetSubKeyNames
|
||||
Dim RemoteApp As New RemoteApp
|
||||
RemoteApp = GetApp(App)
|
||||
SystemAppCollection.Add(RemoteApp)
|
||||
Next
|
||||
|
||||
BaseKey.Close()
|
||||
|
||||
Return SystemAppCollection
|
||||
|
||||
End Function
|
||||
|
||||
Function GetApp(Name As String) As RemoteApp
|
||||
Dim App As New RemoteApp
|
||||
|
||||
Dim AppKey As Microsoft.Win32.RegistryKey = BaseKey.OpenSubKey(Name)
|
||||
|
||||
App.Name = Name
|
||||
App.FullName = AppKey.GetValue("Name", "")
|
||||
App.Path = AppKey.GetValue("Path", "")
|
||||
App.VPath = AppKey.GetValue("VPath", "")
|
||||
App.CommandLine = AppKey.GetValue("RequiredCommandLine", "")
|
||||
App.CommandLineOption = AppKey.GetValue("CommandLineSetting", "1")
|
||||
App.IconPath = AppKey.GetValue("IconPath", "")
|
||||
App.IconIndex = AppKey.GetValue("IconIndex", 0)
|
||||
App.TSWA = AppKey.GetValue("ShowInTSWA", 0)
|
||||
|
||||
Dim FTAKey As Microsoft.Win32.RegistryKey = AppKey.OpenSubKey("Filetypes")
|
||||
If Not FTAKey Is Nothing Then
|
||||
Dim FTACol As New FileTypeAssociationCollection
|
||||
|
||||
For Each FTAValueName As String In FTAKey.GetValueNames
|
||||
Dim FTA As New FileTypeAssociation
|
||||
Dim FTAValue = FTAKey.GetValue(FTAValueName).ToString.Split(",")
|
||||
FTA.Extension = FTAValueName
|
||||
FTA.IconPath = FTAValue(0)
|
||||
FTA.IconIndex = Val(FTAValue(1))
|
||||
|
||||
FTACol.Add(FTA)
|
||||
|
||||
Next
|
||||
|
||||
App.FileTypeAssociations = FTACol
|
||||
End If
|
||||
|
||||
Return App
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub SaveApp(RemoteApp As RemoteApp)
|
||||
BaseKeyWrite.CreateSubKey(RemoteApp.Name)
|
||||
|
||||
Dim AppKey As Microsoft.Win32.RegistryKey = BaseKey.OpenSubKey(RemoteApp.Name, True)
|
||||
|
||||
AppKey.SetValue("Name", RemoteApp.FullName, Microsoft.Win32.RegistryValueKind.String)
|
||||
|
||||
AppKey.SetValue("Path", RemoteApp.Path, Microsoft.Win32.RegistryValueKind.String)
|
||||
AppKey.SetValue("VPath", RemoteApp.VPath, Microsoft.Win32.RegistryValueKind.String)
|
||||
AppKey.SetValue("RequiredCommandLine", RemoteApp.CommandLine, Microsoft.Win32.RegistryValueKind.String)
|
||||
AppKey.SetValue("CommandLineSetting", RemoteApp.CommandLineOption, Microsoft.Win32.RegistryValueKind.DWord)
|
||||
AppKey.SetValue("IconPath", RemoteApp.IconPath, Microsoft.Win32.RegistryValueKind.String)
|
||||
AppKey.SetValue("IconIndex", RemoteApp.IconIndex, Microsoft.Win32.RegistryValueKind.DWord)
|
||||
AppKey.SetValue("ShowInTSWA", RemoteApp.TSWA, Microsoft.Win32.RegistryValueKind.DWord)
|
||||
|
||||
If Not RemoteApp.FileTypeAssociations Is Nothing Then
|
||||
If Not AppKey.OpenSubKey("Filetypes") Is Nothing Then AppKey.DeleteSubKeyTree("Filetypes")
|
||||
AppKey.CreateSubKey("Filetypes")
|
||||
Dim FTAKey = AppKey.OpenSubKey("Filetypes", True)
|
||||
For Each fta As FileTypeAssociation In RemoteApp.FileTypeAssociations
|
||||
FTAKey.SetValue(fta.Extension, fta.IconPath & "," & fta.IconIndex.ToString, Microsoft.Win32.RegistryValueKind.String)
|
||||
Next
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub RenameApp(RemoteAppOldName As String, RemoteAppNewName As String)
|
||||
Dim App As New RemoteApp
|
||||
Dim SystemApps As New SystemRemoteApps
|
||||
|
||||
App = SystemApps.GetApp(RemoteAppOldName)
|
||||
DeleteApp(RemoteAppOldName)
|
||||
App.Name = RemoteAppNewName
|
||||
SaveApp(App)
|
||||
End Sub
|
||||
|
||||
Public Sub DeleteApp(Name As String)
|
||||
BaseKeyWrite.DeleteSubKeyTree(Name)
|
||||
End Sub
|
||||
|
||||
Public Property WoW6432Node As Boolean
|
||||
Get
|
||||
Return Legacy32bit
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
Legacy32bit = value
|
||||
Dim PathStart As String = "SOFTWARE"
|
||||
If Legacy32bit = True Then PathStart = "SOFTWARE\Wow6432Node"
|
||||
RegistryPath = PathStart & "\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList\Applications"
|
||||
End Set
|
||||
End Property
|
||||
|
||||
End Class
|
80
remoteapplib/RemoteAppLib.vbproj
Normal file
80
remoteapplib/RemoteAppLib.vbproj
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{785B6808-B2FE-4C18-9D63-6DAB46482374}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>RemoteAppLib</RootNamespace>
|
||||
<AssemblyName>RemoteAppLib</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Empty</MyType>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="RemoteAppLib.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Reference in New Issue
Block a user