From 48bf324efff04b2ad8ed3a9b3c1ca588a658d1f0 Mon Sep 17 00:00:00 2001 From: ms Date: Mon, 4 Nov 2024 11:39:14 +0100 Subject: [PATCH] Anydesk eingebaut --- Dokumentation/Classes/cExtProgramme.vb | 82 ++++++++++++++++++- .../My Project/Resources.Designer.vb | 2 +- Dokumentation/My Project/Resources.resx | 2 +- Dokumentation/uscntr_TSSitzungen.Designer.vb | 22 +++-- Dokumentation/uscntr_TSSitzungen.vb | 7 ++ 5 files changed, 105 insertions(+), 10 deletions(-) diff --git a/Dokumentation/Classes/cExtProgramme.vb b/Dokumentation/Classes/cExtProgramme.vb index 3614b73..9754051 100644 --- a/Dokumentation/Classes/cExtProgramme.vb +++ b/Dokumentation/Classes/cExtProgramme.vb @@ -2,6 +2,9 @@ Imports System.Management.Automation Imports System.Management.Automation.Runspaces Imports System.Security +Imports System.Diagnostics +Imports System.Text +Imports System.Web Public Class cExtProgramme @@ -20,7 +23,7 @@ Public Class cExtProgramme ElseIf URL = "" Then Exit Function Else - Dim mstsc As New Process + Dim mstsc As New Process mstsc.StartInfo.FileName = "mstsc.exe" mstsc.StartInfo.Arguments = " /v: " & URL mstsc.Start() @@ -143,6 +146,83 @@ Public Class cExtProgramme End Try End Function + + + Public Shared Function RunAnyDeskWithPassword(id As String, Optional password As String = "BmWr501956@4975!") As String + Dim output As New StringBuilder() + Dim err As New StringBuilder() + + Try + Dim processInfo As New ProcessStartInfo("cmd.exe") + processInfo.RedirectStandardInput = True + processInfo.RedirectStandardOutput = True + processInfo.RedirectStandardError = True + processInfo.UseShellExecute = False + processInfo.CreateNoWindow = True + + Using process As Process = Process.Start(processInfo) + Dim command As String = $"echo {password} | ""{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\AnyDesk\AnyDesk-ad_d4025ddb.exe"" {id} --with-password" + process.StandardInput.WriteLine(command) + process.StandardInput.Close() + + ' output.Append(process.StandardOutput.ReadToEnd()) + 'err.Append(process.StandardError.ReadToEnd()) + + 'process.WaitForExit() + End Using + + If err.Length > 0 Then + Console.WriteLine("Fehler: " & err.ToString()) + End If + + Return output.ToString() + Catch ex As Exception + Console.WriteLine("Fehler bei der Ausführung: " & ex.Message) + Return String.Empty + End Try + End Function + + + Public Shared Function PipeStringToProgram(programPath As String, input As String) As String + Dim output As New StringBuilder() + Dim err As New StringBuilder() + + Try + Dim startInfo As New ProcessStartInfo() + startInfo.FileName = programPath + startInfo.UseShellExecute = False + startInfo.RedirectStandardInput = True + startInfo.RedirectStandardOutput = True + startInfo.RedirectStandardError = True + startInfo.CreateNoWindow = False + + Using process As New Process() + process.StartInfo = startInfo + process.Start() + + ' Write the input string to the standard input of the process + Using writer As StreamWriter = process.StandardInput + writer.WriteLine(input) + End Using + + ' Read the output and error streams + output.Append(process.StandardOutput.ReadToEnd()) + err.Append(process.StandardError.ReadToEnd()) + + process.WaitForExit() + End Using + + If err.Length > 0 Then + Console.WriteLine("Error: " & err.ToString()) + End If + + Return output.ToString() + Catch ex As Exception + Console.WriteLine("Error executing program: " & ex.Message) + Return ex.Message + End Try + End Function + Public Shared Function RDPConnect(host As String, Optional ByVal Username As String = "", Optional ByVal Password As String = "", Optional ByVal Fenster As Boolean = False, Optional ByVal admin As Boolean = False) Dim mstsc As New Process Dim AnmeldeDatenVorhanden As Boolean = False diff --git a/Dokumentation/My Project/Resources.Designer.vb b/Dokumentation/My Project/Resources.Designer.vb index 21e8ffe..1431ce7 100644 --- a/Dokumentation/My Project/Resources.Designer.vb +++ b/Dokumentation/My Project/Resources.Designer.vb @@ -309,7 +309,7 @@ Namespace My.Resources End Property ''' - ''' Sucht eine lokalisierte Zeichenfolge, die 0.0.1.94 ähnelt. + ''' Sucht eine lokalisierte Zeichenfolge, die 0.0.1.95 ähnelt. ''' Friend ReadOnly Property Version() As String Get diff --git a/Dokumentation/My Project/Resources.resx b/Dokumentation/My Project/Resources.resx index 7663263..735b7ff 100644 --- a/Dokumentation/My Project/Resources.resx +++ b/Dokumentation/My Project/Resources.resx @@ -149,7 +149,7 @@ ..\Resources\external-content.duckduckgo.com.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - 0.0.1.94 + 0.0.1.95 ..\Resources\mstsc1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/Dokumentation/uscntr_TSSitzungen.Designer.vb b/Dokumentation/uscntr_TSSitzungen.Designer.vb index 1832fb7..a03b2e1 100644 --- a/Dokumentation/uscntr_TSSitzungen.Designer.vb +++ b/Dokumentation/uscntr_TSSitzungen.Designer.vb @@ -30,6 +30,7 @@ Partial Class uscntr_TSSitzungen Me.NachrichtSendenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.UpdateToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ProfildatenÖffnenExplorerToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.TeamVIDKopierenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.Panel1 = New System.Windows.Forms.Panel() Me.lblAnzahl = New System.Windows.Forms.Label() @@ -43,7 +44,7 @@ Partial Class uscntr_TSSitzungen Me.Label1 = New System.Windows.Forms.Label() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.timDisUpdateTimer = New System.Windows.Forms.Timer(Me.components) - Me.TeamVIDKopierenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.VerbindenMitAnydeskToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() CType(Me.dgvTSSitzungen, System.ComponentModel.ISupportInitialize).BeginInit() Me.ContextMenuStrip1.SuspendLayout() Me.Panel1.SuspendLayout() @@ -77,9 +78,9 @@ Partial Class uscntr_TSSitzungen ' 'ContextMenuStrip1 ' - Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.VerbindenMitTeamVToolStripMenuItem, Me.NachrichtSendenToolStripMenuItem, Me.UpdateToolStripMenuItem, Me.ProfildatenÖffnenExplorerToolStripMenuItem, Me.TeamVIDKopierenToolStripMenuItem}) + Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.VerbindenMitTeamVToolStripMenuItem, Me.VerbindenMitAnydeskToolStripMenuItem, Me.NachrichtSendenToolStripMenuItem, Me.UpdateToolStripMenuItem, Me.ProfildatenÖffnenExplorerToolStripMenuItem, Me.TeamVIDKopierenToolStripMenuItem}) Me.ContextMenuStrip1.Name = "ContextMenuStrip1" - Me.ContextMenuStrip1.Size = New System.Drawing.Size(225, 136) + Me.ContextMenuStrip1.Size = New System.Drawing.Size(225, 158) ' 'VerbindenMitTeamVToolStripMenuItem ' @@ -105,6 +106,12 @@ Partial Class uscntr_TSSitzungen Me.ProfildatenÖffnenExplorerToolStripMenuItem.Size = New System.Drawing.Size(224, 22) Me.ProfildatenÖffnenExplorerToolStripMenuItem.Text = "Profildaten öffnen (Explorer)" ' + 'TeamVIDKopierenToolStripMenuItem + ' + Me.TeamVIDKopierenToolStripMenuItem.Name = "TeamVIDKopierenToolStripMenuItem" + Me.TeamVIDKopierenToolStripMenuItem.Size = New System.Drawing.Size(224, 22) + Me.TeamVIDKopierenToolStripMenuItem.Text = "TeamV. ID kopieren" + ' 'Timer1 ' Me.Timer1.Interval = 10000 @@ -259,11 +266,11 @@ Partial Class uscntr_TSSitzungen ' Me.timDisUpdateTimer.Interval = 60000 ' - 'TeamVIDKopierenToolStripMenuItem + 'VerbindenMitAnydeskToolStripMenuItem ' - Me.TeamVIDKopierenToolStripMenuItem.Name = "TeamVIDKopierenToolStripMenuItem" - Me.TeamVIDKopierenToolStripMenuItem.Size = New System.Drawing.Size(224, 22) - Me.TeamVIDKopierenToolStripMenuItem.Text = "TeamV. ID kopieren" + Me.VerbindenMitAnydeskToolStripMenuItem.Name = "VerbindenMitAnydeskToolStripMenuItem" + Me.VerbindenMitAnydeskToolStripMenuItem.Size = New System.Drawing.Size(224, 22) + Me.VerbindenMitAnydeskToolStripMenuItem.Text = "Verbinden mit Anydesk" ' 'uscntr_TSSitzungen ' @@ -307,4 +314,5 @@ Partial Class uscntr_TSSitzungen Public WithEvents btnReset As Button Friend WithEvents timDisUpdateTimer As Timer Friend WithEvents TeamVIDKopierenToolStripMenuItem As ToolStripMenuItem + Friend WithEvents VerbindenMitAnydeskToolStripMenuItem As ToolStripMenuItem End Class diff --git a/Dokumentation/uscntr_TSSitzungen.vb b/Dokumentation/uscntr_TSSitzungen.vb index baa8a0a..911ce0c 100644 --- a/Dokumentation/uscntr_TSSitzungen.vb +++ b/Dokumentation/uscntr_TSSitzungen.vb @@ -248,4 +248,11 @@ Private Sub TeamVIDKopierenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TeamVIDKopierenToolStripMenuItem.Click Clipboard.SetText(Class1.DBNull2emptyString(dgvTSSitzungen.CurrentRow.Cells("TeamviewerID").Value)) End Sub + + Private Sub VerbindenMitAnydeskToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VerbindenMitAnydeskToolStripMenuItem.Click + Dim Name As String = Class1.DBNull2emptyString(dgvTSSitzungen.CurrentRow.Cells("BenutzerAnmeldeName").Value) + Name = Name.Substring(Name.LastIndexOf("\") + 1) + Dim sitzung As String = Class1.DBNull2emptyString(dgvTSSitzungen.CurrentRow.Cells("TSServer").Value) & "\" & Name + cExtProgramme.RunAnyDeskWithPassword(sitzung) + End Sub End Class