mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da39c03a6f | ||
|
|
3d64fbef49 | ||
|
|
869c2726bb | ||
|
|
2e663df42a | ||
|
|
0a82828d2e | ||
|
|
13c1d049fc |
@@ -1,8 +1,21 @@
|
||||
1.71 (2013-10-16):
|
||||
1.72 (2013-11-13):
|
||||
Fixed issue MR-592 - Unable to run VBS script as an external tool
|
||||
Fixed issue MR-596 - Incorrect escaping of quotation marks in external tool arguments
|
||||
|
||||
1.71 (2013-10-29):
|
||||
Fixed issue MR-574 - Crash when retrieving RDP session list if eolwtscom.dll is not registered
|
||||
Fixed issue MR-578 - Connections file is reset
|
||||
Fixed log file not showing operating system version on Windows XP and Windows Server 2003.
|
||||
Fixed the wrong connections file opening on startup under certain conditions.
|
||||
Fixed checking for updates even when disabled.
|
||||
Improved error reporting when loading connections files.
|
||||
Removed warning message when mRemoteNG is started for the first time about new connections file being created.
|
||||
|
||||
1.71 Release Candidate 2 (2013-10-16):
|
||||
Fixed issue MR-560 - Cannot Auto-Update With Open Connections: Unable to find an entry point named 'TaskDialogIndirect' in DLL 'ComCtl32'
|
||||
Fixed issue MR-565 - Double Folder keep heritage on the initial Folder
|
||||
Fixed issue MR-566 - Typo in German UI Automatic Update Settings
|
||||
Fixed duplicated folders possibly being named "New Connection" instead of the original folder's name
|
||||
Fixed duplicated folders possibly being named "New Connection" instead of the original folder's name.
|
||||
|
||||
1.71 Release Candidate 1 (2013-10-01):
|
||||
Fixed issue MR-495 - Having a negative range in port scan creates memory exhaustion.
|
||||
|
||||
@@ -503,20 +503,30 @@ Namespace App
|
||||
#End If
|
||||
Log.InfoFormat("Command Line: {0}", Environment.GetCommandLineArgs)
|
||||
|
||||
Dim osVersion As String = String.Empty
|
||||
Dim servicePack As String = String.Empty
|
||||
Try
|
||||
Dim servicePack As Integer
|
||||
For Each managementObject As ManagementObject In New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get()
|
||||
servicePack = managementObject.GetPropertyValue("ServicePackMajorVersion")
|
||||
If servicePack = 0 Then
|
||||
Log.InfoFormat("{0} {1}", managementObject.GetPropertyValue("Caption").Trim, managementObject.GetPropertyValue("OSArchitecture"))
|
||||
Else
|
||||
Log.InfoFormat("{0} Service Pack {1} {2}", managementObject.GetPropertyValue("Caption").Trim, servicePack.ToString, managementObject.GetPropertyValue("OSArchitecture"))
|
||||
End If
|
||||
For Each managementObject As ManagementObject In New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True").Get()
|
||||
osVersion = managementObject.GetPropertyValue("Caption").Trim()
|
||||
Dim servicePackNumber As Integer = managementObject.GetPropertyValue("ServicePackMajorVersion")
|
||||
If Not servicePackNumber = 0 Then servicePack = String.Format("Service Pack {0}", servicePackNumber)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log.WarnFormat("Error retrieving operating system information from WMI. {0}", ex.Message)
|
||||
End Try
|
||||
|
||||
Dim architecture As String = String.Empty
|
||||
Try
|
||||
For Each managementObject As ManagementObject In New ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID='CPU0'").Get()
|
||||
Dim addressWidth As Integer = managementObject.GetPropertyValue("AddressWidth")
|
||||
architecture = String.Format("{0}-bit", addressWidth)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Log.WarnFormat("Error retrieving operating system address width from WMI. {0}", ex.Message)
|
||||
End Try
|
||||
|
||||
Log.InfoFormat(String.Join(" ", Array.FindAll(New String() {osVersion, servicePack, architecture}, Function(s) Not String.IsNullOrEmpty(s))))
|
||||
|
||||
Log.InfoFormat("Microsoft .NET CLR {0}", Version.ToString)
|
||||
Log.InfoFormat("System Culture: {0}/{1}", Thread.CurrentThread.CurrentUICulture.Name, Thread.CurrentThread.CurrentUICulture.NativeName)
|
||||
End If
|
||||
@@ -979,41 +989,54 @@ Namespace App
|
||||
ConnectionList = New Connection.List
|
||||
ContainerList = New Container.List
|
||||
|
||||
Dim conL As New Config.Connections.Load
|
||||
Dim connectionsLoad As New Connections.Load
|
||||
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
If filename = GetDefaultStartupConnectionFileName() Then
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
Else
|
||||
My.Settings.LoadConsFromCustomLocation = True
|
||||
My.Settings.CustomConsPath = filename
|
||||
End If
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filename))
|
||||
Dim xW As New XmlTextWriter(filename, System.Text.Encoding.UTF8)
|
||||
xW.Formatting = Formatting.Indented
|
||||
xW.Indentation = 4
|
||||
|
||||
xW.WriteStartDocument()
|
||||
xW.WriteStartElement("Connections") ' Do not localize
|
||||
xW.WriteAttributeString("Name", My.Language.strConnections)
|
||||
xW.WriteAttributeString("Export", "", "False")
|
||||
xW.WriteAttributeString("Protected", "", "GiUis20DIbnYzWPcdaQKfjE2H5jh//L5v4RGrJMGNXuIq2CttB/d/BxaBP2LwRhY")
|
||||
xW.WriteAttributeString("ConfVersion", "", "2.5")
|
||||
' Use File.Open with FileMode.CreateNew so that we don't overwrite an existing file
|
||||
Using fileStream As FileStream = File.Open(filename, FileMode.CreateNew, FileAccess.Write, FileShare.None)
|
||||
Using xmlTextWriter As New XmlTextWriter(fileStream, System.Text.Encoding.UTF8)
|
||||
With xmlTextWriter
|
||||
.Formatting = Formatting.Indented
|
||||
.Indentation = 4
|
||||
|
||||
xW.WriteEndElement()
|
||||
xW.WriteEndDocument()
|
||||
.WriteStartDocument()
|
||||
|
||||
xW.Close()
|
||||
.WriteStartElement("Connections") ' Do not localize
|
||||
.WriteAttributeString("Name", My.Language.strConnections)
|
||||
.WriteAttributeString("Export", "", "False")
|
||||
.WriteAttributeString("Protected", "", "GiUis20DIbnYzWPcdaQKfjE2H5jh//L5v4RGrJMGNXuIq2CttB/d/BxaBP2LwRhY")
|
||||
.WriteAttributeString("ConfVersion", "", "2.5")
|
||||
|
||||
conL.ConnectionList = ConnectionList
|
||||
conL.ContainerList = ContainerList
|
||||
.WriteEndElement()
|
||||
.WriteEndDocument()
|
||||
|
||||
.Close()
|
||||
End With
|
||||
End Using
|
||||
End Using
|
||||
|
||||
connectionsLoad.ConnectionList = ConnectionList
|
||||
connectionsLoad.ContainerList = ContainerList
|
||||
|
||||
Tree.Node.ResetTree()
|
||||
|
||||
conL.RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
|
||||
connectionsLoad.RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
|
||||
|
||||
' Load config
|
||||
conL.ConnectionFileName = filename
|
||||
conL.Load(False)
|
||||
connectionsLoad.ConnectionFileName = filename
|
||||
connectionsLoad.Load(False)
|
||||
|
||||
Windows.treeForm.tvConnections.SelectedNode = conL.RootTreeNode
|
||||
Windows.treeForm.tvConnections.SelectedNode = connectionsLoad.RootTreeNode
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strCouldNotCreateNewConnectionsFile & vbNewLine & ex.Message)
|
||||
MessageCollector.AddExceptionMessage(My.Language.strCouldNotCreateNewConnectionsFile, ex, MessageClass.ErrorMsg)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -1032,8 +1055,8 @@ Namespace App
|
||||
LoadConnections(_withDialog, _loadUpdate)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadConnections(Optional ByVal WithDialog As Boolean = False, Optional ByVal Update As Boolean = False)
|
||||
Dim conL As New Config.Connections.Load
|
||||
Public Shared Sub LoadConnections(Optional ByVal withDialog As Boolean = False, Optional ByVal update As Boolean = False)
|
||||
Dim connectionsLoad As New Connections.Load
|
||||
|
||||
Try
|
||||
Dim tmrWasEnabled As Boolean
|
||||
@@ -1053,66 +1076,55 @@ Namespace App
|
||||
ConnectionList = New Connection.List
|
||||
ContainerList = New Container.List
|
||||
|
||||
If My.Settings.UseSQLServer = False Then
|
||||
If WithDialog Then
|
||||
Dim lD As OpenFileDialog = Tools.Controls.ConnectionsLoadDialog
|
||||
If Not My.Settings.UseSQLServer Then
|
||||
If withDialog Then
|
||||
Dim loadDialog As OpenFileDialog = Controls.ConnectionsLoadDialog
|
||||
|
||||
If lD.ShowDialog = System.Windows.Forms.DialogResult.OK Then
|
||||
conL.ConnectionFileName = lD.FileName
|
||||
If loadDialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then
|
||||
connectionsLoad.ConnectionFileName = loadDialog.FileName
|
||||
Else
|
||||
Exit Sub
|
||||
End If
|
||||
Else
|
||||
conL.ConnectionFileName = GetStartupConnectionFileName()
|
||||
connectionsLoad.ConnectionFileName = GetStartupConnectionFileName()
|
||||
End If
|
||||
|
||||
If File.Exists(conL.ConnectionFileName) = False Then
|
||||
If WithDialog Then
|
||||
MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, String.Format(My.Language.strConnectionsFileCouldNotBeLoaded, conL.ConnectionFileName))
|
||||
Else
|
||||
MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, String.Format(My.Language.strConnectionsFileCouldNotBeLoadedNew, conL.ConnectionFileName))
|
||||
App.Runtime.NewConnections(conL.ConnectionFileName)
|
||||
End If
|
||||
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
CreateBackupFile(conL.ConnectionFileName)
|
||||
CreateBackupFile(connectionsLoad.ConnectionFileName)
|
||||
End If
|
||||
|
||||
conL.ConnectionList = ConnectionList
|
||||
conL.ContainerList = ContainerList
|
||||
connectionsLoad.ConnectionList = ConnectionList
|
||||
connectionsLoad.ContainerList = ContainerList
|
||||
|
||||
If PreviousConnectionList IsNot Nothing And PreviousContainerList IsNot Nothing Then
|
||||
conL.PreviousConnectionList = PreviousConnectionList
|
||||
conL.PreviousContainerList = PreviousContainerList
|
||||
connectionsLoad.PreviousConnectionList = PreviousConnectionList
|
||||
connectionsLoad.PreviousContainerList = PreviousContainerList
|
||||
End If
|
||||
|
||||
If Update = True Then
|
||||
conL.PreviousSelected = LastSelected
|
||||
If update = True Then
|
||||
connectionsLoad.PreviousSelected = LastSelected
|
||||
End If
|
||||
|
||||
Tree.Node.ResetTree()
|
||||
|
||||
conL.RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
|
||||
connectionsLoad.RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
|
||||
|
||||
conL.UseSQL = My.Settings.UseSQLServer
|
||||
conL.SQLHost = My.Settings.SQLHost
|
||||
conL.SQLDatabaseName = My.Settings.SQLDatabaseName
|
||||
conL.SQLUsername = My.Settings.SQLUser
|
||||
conL.SQLPassword = Security.Crypt.Decrypt(My.Settings.SQLPass, App.Info.General.EncryptionKey)
|
||||
conL.SQLUpdate = Update
|
||||
connectionsLoad.UseSQL = My.Settings.UseSQLServer
|
||||
connectionsLoad.SQLHost = My.Settings.SQLHost
|
||||
connectionsLoad.SQLDatabaseName = My.Settings.SQLDatabaseName
|
||||
connectionsLoad.SQLUsername = My.Settings.SQLUser
|
||||
connectionsLoad.SQLPassword = Security.Crypt.Decrypt(My.Settings.SQLPass, Info.General.EncryptionKey)
|
||||
connectionsLoad.SQLUpdate = update
|
||||
|
||||
conL.Load(False)
|
||||
connectionsLoad.Load(False)
|
||||
|
||||
If My.Settings.UseSQLServer = True Then
|
||||
LastSqlUpdate = Now
|
||||
Else
|
||||
If conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile Then
|
||||
If connectionsLoad.ConnectionFileName = GetDefaultStartupConnectionFileName() Then
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
Else
|
||||
My.Settings.LoadConsFromCustomLocation = True
|
||||
My.Settings.CustomConsPath = conL.ConnectionFileName
|
||||
My.Settings.CustomConsPath = connectionsLoad.ConnectionFileName
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -1126,20 +1138,26 @@ Namespace App
|
||||
cTaskDialog.ShowCommandBox(Application.ProductName, My.Language.strLoadFromSqlFailed, My.Language.strLoadFromSqlFailedContent, Misc.GetExceptionMessageRecursive(ex), "", "", commandButtons, False, eSysIcons.Error, Nothing)
|
||||
Select Case cTaskDialog.CommandButtonResult
|
||||
Case 0
|
||||
LoadConnections(WithDialog, Update)
|
||||
LoadConnections(withDialog, update)
|
||||
Return
|
||||
Case 1
|
||||
My.Settings.UseSQLServer = False
|
||||
LoadConnections(True, Update)
|
||||
LoadConnections(True, update)
|
||||
Return
|
||||
Case Else
|
||||
Application.Exit()
|
||||
Return
|
||||
End Select
|
||||
Else
|
||||
MessageCollector.AddExceptionMessage(String.Format(My.Language.strConnectionsFileCouldNotBeLoaded, conL.ConnectionFileName), ex)
|
||||
If Not conL.ConnectionFileName = GetStartupConnectionFileName() Then
|
||||
LoadConnections(WithDialog, Update)
|
||||
If TypeOf ex Is FileNotFoundException And Not withDialog Then
|
||||
MessageCollector.AddExceptionMessage(String.Format(My.Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoad.ConnectionFileName), ex, MessageClass.InformationMsg)
|
||||
NewConnections(connectionsLoad.ConnectionFileName)
|
||||
Return
|
||||
End If
|
||||
|
||||
MessageCollector.AddExceptionMessage(String.Format(My.Language.strConnectionsFileCouldNotBeLoaded, connectionsLoad.ConnectionFileName), ex)
|
||||
If Not connectionsLoad.ConnectionFileName = GetStartupConnectionFileName() Then
|
||||
LoadConnections(withDialog, update)
|
||||
Return
|
||||
Else
|
||||
MsgBox(String.Format(My.Language.strErrorStartupConnectionFileLoad, vbNewLine, Application.ProductName, GetStartupConnectionFileName(), Misc.GetExceptionMessageRecursive(ex)), MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
|
||||
@@ -1159,7 +1177,7 @@ Namespace App
|
||||
File.Copy(fileName, backupFileName)
|
||||
PruneBackupFiles(fileName)
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(MessageClass.WarningMsg, My.Language.strConnectionsFileBackupFailed & vbNewLine & vbNewLine & ex.Message)
|
||||
MessageCollector.AddExceptionMessage(My.Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg)
|
||||
Throw
|
||||
End Try
|
||||
End Sub
|
||||
@@ -1183,26 +1201,23 @@ Namespace App
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Protected Shared Function GetStartupConnectionFileName() As String
|
||||
Dim fileName As New String("")
|
||||
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
Dim newPath As String = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
Public Shared Function GetDefaultStartupConnectionFileName() As String
|
||||
Dim newPath As String = App.Info.Connections.DefaultConnectionsPath & "\" & Info.Connections.DefaultConnectionsFile
|
||||
#If Not PORTABLE Then
|
||||
If File.Exists(oldPath) Then
|
||||
fileName = oldPath
|
||||
Else
|
||||
fileName = newPath
|
||||
End If
|
||||
#Else
|
||||
fileName = newPath
|
||||
#End If
|
||||
Else
|
||||
fileName = My.Settings.CustomConsPath
|
||||
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & Info.Connections.DefaultConnectionsFile
|
||||
If File.Exists(oldPath) Then
|
||||
Return oldPath
|
||||
End If
|
||||
#End If
|
||||
Return newPath
|
||||
End Function
|
||||
|
||||
Return fileName
|
||||
Public Shared Function GetStartupConnectionFileName() As String
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
Return GetDefaultStartupConnectionFileName()
|
||||
Else
|
||||
Return My.Settings.CustomConsPath
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Sub ImportConnections()
|
||||
@@ -1487,12 +1502,8 @@ Namespace App
|
||||
|
||||
Dim conS As New Config.Connections.Save
|
||||
|
||||
If My.Settings.UseSQLServer = False Then
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
conS.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
Else
|
||||
conS.ConnectionFileName = My.Settings.CustomConsPath
|
||||
End If
|
||||
If Not My.Settings.UseSQLServer Then
|
||||
conS.ConnectionFileName = GetStartupConnectionFileName()
|
||||
End If
|
||||
|
||||
conS.ConnectionList = ConnectionList
|
||||
@@ -1561,7 +1572,7 @@ Namespace App
|
||||
Else
|
||||
connectionsSave.SaveFormat = Config.Connections.Save.Format.mRXML
|
||||
|
||||
If connectionsSave.ConnectionFileName = Info.Connections.DefaultConnectionsPath & "\" & Info.Connections.DefaultConnectionsFile Then
|
||||
If connectionsSave.ConnectionFileName = GetDefaultStartupConnectionFileName() Then
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
Else
|
||||
My.Settings.LoadConsFromCustomLocation = True
|
||||
|
||||
@@ -87,9 +87,9 @@ Namespace Connection
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
IntAppProcessStartInfo.UseShellExecute = False
|
||||
IntAppProcessStartInfo.UseShellExecute = True
|
||||
IntAppProcessStartInfo.FileName = _IntAppPath
|
||||
IntAppProcessStartInfo.Arguments = CommandLineArguments.EscapeBackslashes(Arguments)
|
||||
IntAppProcessStartInfo.Arguments = Arguments
|
||||
|
||||
IntAppProcess = Process.Start(IntAppProcessStartInfo)
|
||||
IntAppProcess.EnableRaisingEvents = True
|
||||
|
||||
@@ -635,77 +635,91 @@ Namespace Connection
|
||||
|
||||
#Region "Terminal Sessions"
|
||||
Public Class TerminalSessions
|
||||
Dim oWTSCOM As New WTSCOM
|
||||
Dim oWTSSessions As New WTSSessions
|
||||
Dim oWTSSession As New WTSSession
|
||||
Public ServerHandle As Long
|
||||
Private ReadOnly _wtsCom As WTSCOM
|
||||
|
||||
Public Function OpenConnection(ByVal SrvName As String) As Boolean
|
||||
Public Sub New()
|
||||
Try
|
||||
ServerHandle = oWTSCOM.WTSOpenServer(SrvName)
|
||||
|
||||
If ServerHandle <> 0 Then
|
||||
Return True
|
||||
End If
|
||||
_wtsCom = New WTSCOM
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpOpenConnectionFailed & vbNewLine & ex.Message, True)
|
||||
End Try
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Sub CloseConnection(ByVal SrvHandle As Long)
|
||||
Try
|
||||
oWTSCOM.WTSCloseServer(ServerHandle)
|
||||
ServerHandle = 0
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpCloseConnectionFailed & vbNewLine & ex.Message, True)
|
||||
MessageCollector.AddExceptionMessage("TerminalSessions.New() failed.", ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Function GetSessions() As Sessions
|
||||
Dim colSessions As New Sessions
|
||||
Public Function OpenConnection(ByVal hostname As String) As Long
|
||||
If _wtsCom Is Nothing Then Return 0
|
||||
|
||||
Try
|
||||
oWTSSessions = oWTSCOM.WTSEnumerateSessions(ServerHandle)
|
||||
Return _wtsCom.WTSOpenServer(hostname)
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddExceptionMessage(My.Language.strRdpOpenConnectionFailed, ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Dim SessionID As Long
|
||||
Dim SessionUser As String
|
||||
Dim SessionState As Long
|
||||
Dim SessionName As String
|
||||
Public Sub CloseConnection(ByVal serverHandle As Long)
|
||||
If _wtsCom Is Nothing Then Return
|
||||
|
||||
For Each oWTSSession In oWTSSessions
|
||||
SessionID = oWTSSession.SessionId
|
||||
SessionUser = oWTSCOM.WTSQuerySessionInformation(ServerHandle, oWTSSession.SessionId, 5) 'WFUsername = 5
|
||||
SessionState = oWTSSession.State & vbCrLf
|
||||
SessionName = oWTSSession.WinStationName & vbCrLf
|
||||
Try
|
||||
_wtsCom.WTSCloseServer(serverHandle)
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddExceptionMessage(My.Language.strRdpCloseConnectionFailed, ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
If SessionUser <> "" Then
|
||||
If SessionState = 0 Then
|
||||
colSessions.Add(SessionID, My.Language.strActive, SessionUser, SessionName)
|
||||
Public Function GetSessions(ByVal serverHandle As Long) As SessionsCollection
|
||||
If _wtsCom Is Nothing Then Return New SessionsCollection()
|
||||
|
||||
Dim sessions As New SessionsCollection()
|
||||
|
||||
Try
|
||||
Dim wtsSessions As WTSSessions = _wtsCom.WTSEnumerateSessions(serverHandle)
|
||||
|
||||
Dim sessionId As Long
|
||||
Dim sessionUser As String
|
||||
Dim sessionState As Long
|
||||
Dim sessionName As String
|
||||
|
||||
For Each wtsSession As WTSSession In wtsSessions
|
||||
sessionId = wtsSession.SessionId
|
||||
sessionUser = _wtsCom.WTSQuerySessionInformation(serverHandle, wtsSession.SessionId, 5) ' WFUsername = 5
|
||||
sessionState = wtsSession.State & vbCrLf
|
||||
sessionName = wtsSession.WinStationName & vbCrLf
|
||||
|
||||
If Not String.IsNullOrEmpty(sessionUser) Then
|
||||
If sessionState = 0 Then
|
||||
sessions.Add(sessionId, My.Language.strActive, sessionUser, sessionName)
|
||||
Else
|
||||
colSessions.Add(SessionID, My.Language.strInactive, SessionUser, SessionName)
|
||||
sessions.Add(sessionId, My.Language.strInactive, sessionUser, sessionName)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpGetSessionsFailed & vbNewLine & ex.Message, True)
|
||||
MessageCollector.AddExceptionMessage(My.Language.strRdpGetSessionsFailed, ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
|
||||
Return colSessions
|
||||
Return sessions
|
||||
End Function
|
||||
|
||||
Public Function KillSession(ByVal SessionID As Long) As Boolean
|
||||
Return oWTSCOM.WTSLogoffSession(ServerHandle, SessionID, True)
|
||||
Public Function KillSession(ByVal serverHandle As Long, ByVal sessionId As Long) As Boolean
|
||||
If _wtsCom Is Nothing Then Return False
|
||||
|
||||
Dim result As Boolean = False
|
||||
|
||||
Try
|
||||
result = _wtsCom.WTSLogoffSession(serverHandle, sessionId, True)
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddExceptionMessage("TerminalSessions.KillSession() failed.", ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
|
||||
Return result
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Class Sessions
|
||||
Public Class SessionsCollection
|
||||
Inherits CollectionBase
|
||||
|
||||
Default Public ReadOnly Property Items(ByVal Index As Integer) As Session
|
||||
Default Public ReadOnly Property Items(ByVal index As Integer) As Session
|
||||
Get
|
||||
Return CType(List.Item(Index), Session)
|
||||
Return CType(List.Item(index), Session)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -715,23 +729,23 @@ Namespace Connection
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Function Add(ByVal SessionID As Long, ByVal SessionState As String, ByVal SessionUser As String, ByVal SessionName As String) As Session
|
||||
Dim newSes As New Session
|
||||
Public Overloads Function Add(ByVal sessionId As Long, ByVal sessionState As String, ByVal sessionUser As String, ByVal sessionName As String) As Session
|
||||
Dim newSession As New Session
|
||||
|
||||
Try
|
||||
With newSes
|
||||
.SessionID = SessionID
|
||||
.SessionState = SessionState
|
||||
.SessionUser = SessionUser
|
||||
.SessionName = SessionName
|
||||
With newSession
|
||||
.SessionId = sessionId
|
||||
.SessionState = sessionState
|
||||
.SessionUser = sessionUser
|
||||
.SessionName = sessionName
|
||||
End With
|
||||
|
||||
List.Add(newSes)
|
||||
List.Add(newSession)
|
||||
Catch ex As Exception
|
||||
MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strRdpAddSessionFailed & vbNewLine & ex.Message, True)
|
||||
MessageCollector.AddExceptionMessage(My.Language.strRdpAddSessionFailed, ex, MessageClass.ErrorMsg, True)
|
||||
End Try
|
||||
|
||||
Return newSes
|
||||
Return newSession
|
||||
End Function
|
||||
|
||||
Public Sub ClearSessions()
|
||||
@@ -742,45 +756,10 @@ Namespace Connection
|
||||
Public Class Session
|
||||
Inherits CollectionBase
|
||||
|
||||
Private lngSessionID As Long
|
||||
Public Property SessionID() As Long
|
||||
Get
|
||||
Return lngSessionID
|
||||
End Get
|
||||
Set(ByVal Value As Long)
|
||||
lngSessionID = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private lngSessionState As String
|
||||
Public Property SessionId() As Long
|
||||
Public Property SessionState() As String
|
||||
Get
|
||||
Return lngSessionState
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
lngSessionState = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private strSessionUser As String
|
||||
Public Property SessionUser() As String
|
||||
Get
|
||||
Return strSessionUser
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
strSessionUser = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private strSessionName As String
|
||||
Public Property SessionName() As String
|
||||
Get
|
||||
Return strSessionName
|
||||
End Get
|
||||
Set(ByVal Value As String)
|
||||
strSessionName = Value
|
||||
End Set
|
||||
End Property
|
||||
End Class
|
||||
#End Region
|
||||
|
||||
|
||||
@@ -67,6 +67,12 @@ Public Class frmMain
|
||||
|
||||
Tree.Node.TreeView = Windows.treeForm.tvConnections
|
||||
|
||||
If My.Settings.FirstStart And _
|
||||
Not My.Settings.LoadConsFromCustomLocation And _
|
||||
Not IO.File.Exists(GetStartupConnectionFileName()) Then
|
||||
NewConnections(GetStartupConnectionFileName())
|
||||
End If
|
||||
|
||||
'LoadCredentials()
|
||||
LoadConnections()
|
||||
If Not IsConnectionsFileLoaded Then
|
||||
@@ -200,7 +206,9 @@ Public Class frmMain
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
#If Not PORTABLE Then
|
||||
#If PORTABLE Then
|
||||
Return
|
||||
#End If
|
||||
If Not My.Settings.CheckForUpdatesAsked Then
|
||||
Dim commandButtons() As String = {My.Language.strAskUpdatesCommandRecommended, My.Language.strAskUpdatesCommandCustom, My.Language.strAskUpdatesCommandAskLater}
|
||||
cTaskDialog.ShowTaskDialogBox(Me, My.Application.Info.ProductName, My.Language.strAskUpdatesMainInstruction, String.Format(My.Language.strAskUpdatesContent, My.Application.Info.ProductName), "", "", "", "", String.Join("|", commandButtons), eTaskDialogButtons.None, eSysIcons.Question, eSysIcons.Question)
|
||||
@@ -210,15 +218,17 @@ Public Class frmMain
|
||||
If cTaskDialog.CommandButtonResult = 1 Then
|
||||
Windows.ShowUpdatesTab()
|
||||
End If
|
||||
Return
|
||||
End If
|
||||
|
||||
If Not My.Settings.CheckForUpdatesOnStartup Then Return
|
||||
|
||||
Dim nextUpdateCheck As Date = My.Settings.CheckForUpdatesLastCheck.Add(TimeSpan.FromDays(My.Settings.CheckForUpdatesFrequencyDays))
|
||||
If My.Settings.UpdatePending Or Date.UtcNow > nextUpdateCheck Then
|
||||
If Not IsHandleCreated Then CreateHandle() ' Make sure the handle is created so that InvokeRequired returns the correct result
|
||||
Startup.CheckForUpdate()
|
||||
Startup.CheckForAnnouncement()
|
||||
End If
|
||||
#End If
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
|
||||
|
||||
@@ -1810,11 +1810,7 @@ Public Class frmOptions
|
||||
ThemeManager.SaveThemes(_themeList)
|
||||
Settings.ThemeName = ThemeManager.ActiveTheme.Name
|
||||
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
App.Runtime.SetMainFormText(App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile)
|
||||
Else
|
||||
App.Runtime.SetMainFormText(My.Settings.CustomConsPath)
|
||||
End If
|
||||
SetMainFormText(GetStartupConnectionFileName())
|
||||
|
||||
App.Runtime.Startup.DestroySQLUpdateHandlerAndStopTimer()
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
|
||||
' by using the '*' as shown below:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.71.*")>
|
||||
<Assembly: AssemblyVersion("1.72.*")>
|
||||
|
||||
<Assembly: NeutralResourcesLanguageAttribute("en")>
|
||||
|
||||
@@ -119,10 +119,10 @@ Namespace Tools
|
||||
|
||||
Dim process As New Process()
|
||||
With process.StartInfo
|
||||
.UseShellExecute = False
|
||||
.UseShellExecute = True
|
||||
.FileName = ParseText(_FileName)
|
||||
|
||||
.Arguments = CommandLineArguments.EscapeBackslashes(ParseText(_Arguments))
|
||||
.Arguments = ParseText(_Arguments)
|
||||
End With
|
||||
|
||||
process.Start()
|
||||
|
||||
@@ -129,10 +129,10 @@ Namespace UI
|
||||
With data
|
||||
impersonator.StartImpersonation(.Domain, .Username, .Password)
|
||||
|
||||
If Not terminalSessions.OpenConnection(.Hostname) Then Return
|
||||
serverHandle = terminalSessions.ServerHandle
|
||||
serverHandle = terminalSessions.OpenConnection(.Hostname)
|
||||
If serverHandle = 0 Then Return
|
||||
|
||||
GetSessions(terminalSessions)
|
||||
GetSessions(terminalSessions, serverHandle)
|
||||
End With
|
||||
|
||||
_retrieved = True
|
||||
@@ -149,11 +149,11 @@ Namespace UI
|
||||
End Sub
|
||||
|
||||
' Get sessions from an already impersonated and connected TerminalSessions object
|
||||
Private Sub GetSessions(ByVal terminalSessions As mRemoteNG.Connection.Protocol.RDP.TerminalSessions)
|
||||
Dim rdpSessions As mRemoteNG.Connection.Protocol.RDP.Sessions = terminalSessions.GetSessions
|
||||
Private Sub GetSessions(ByVal terminalSessions As mRemoteNG.Connection.Protocol.RDP.TerminalSessions, ByVal serverHandle As Long)
|
||||
Dim rdpSessions As mRemoteNG.Connection.Protocol.RDP.SessionsCollection = terminalSessions.GetSessions(serverHandle)
|
||||
For Each session As mRemoteNG.Connection.Protocol.RDP.Session In rdpSessions
|
||||
Dim item As New ListViewItem
|
||||
item.Tag = session.SessionID
|
||||
item.Tag = session.SessionId
|
||||
item.Text = session.SessionUser
|
||||
item.SubItems.Add(session.SessionState)
|
||||
item.SubItems.Add(Replace(session.SessionName, vbNewLine, ""))
|
||||
@@ -174,13 +174,13 @@ Namespace UI
|
||||
|
||||
impersonator.StartImpersonation(.Domain, .Username, .Password)
|
||||
|
||||
If terminalSessions.OpenConnection(.Hostname) Then
|
||||
serverHandle = terminalSessions.ServerHandle
|
||||
terminalSessions.KillSession(.SessionId)
|
||||
serverHandle = terminalSessions.OpenConnection(.Hostname)
|
||||
If Not serverHandle = 0 Then
|
||||
terminalSessions.KillSession(serverHandle, .SessionId)
|
||||
End If
|
||||
|
||||
ClearList()
|
||||
GetSessions(terminalSessions)
|
||||
GetSessions(terminalSessions, serverHandle)
|
||||
|
||||
_retrieved = True
|
||||
End With
|
||||
|
||||
Reference in New Issue
Block a user