Update VeragProgAllgemein; Feature: RDP direkt starten;

This commit is contained in:
ms
2022-11-22 10:53:34 +01:00
parent 67f2a10607
commit f717deac50
31 changed files with 900 additions and 315 deletions

View File

@@ -0,0 +1,25 @@
Imports Chilkat
Public Class cChilkat_Helper
Public Shared Sub UnlockCilkat()
Dim glob As Chilkat.[Global] = New Chilkat.[Global]()
Dim success As Boolean = glob.UnlockBundle("VERAGS.CB1122022_JJ6kgS2zoR0g")
If success <> True Then
Debug.WriteLine(glob.LastErrorText)
Return
End If
Dim status As Integer = glob.UnlockStatus
If status = 2 Then
Debug.WriteLine("Unlocked using purchased unlock code.")
Else
Debug.WriteLine("Unlocked in trial mode.")
End If
Debug.WriteLine(glob.LastErrorText)
End Sub
End Class

View File

@@ -1,4 +1,6 @@
Public Class cExtProgramme
Imports System.IO
Public Class cExtProgramme
Public Shared Function startlink(URL As String)
@@ -24,16 +26,16 @@
End Function
Public Shared Function startputty(IP As String)
Public Shared Function startputty(IP As String, Optional ByVal Port As Integer = 22)
Dim Benutzer, Passwort As String
Class1.GetUserPasswort(IP, Benutzer, Passwort)
Try
Dim putty As New Process
putty.StartInfo.FileName = "putty.exe"
If Benutzer = "" And Passwort = "" Then
putty.StartInfo.Arguments = IP
putty.StartInfo.Arguments = IP & " -P " & Port
Else
putty.StartInfo.Arguments = IP & " -l " & Benutzer & " -pw " & Passwort
putty.StartInfo.Arguments = IP & " -P " & Port & " -l " & Benutzer & " -pw " & Passwort
End If
putty.Start()
@@ -43,6 +45,15 @@
End Try
End Function
Public Shared Function commandcmd(command As String)
Dim cmd As New Process
cmd.StartInfo.FileName = "cmd.exe"
cmd.StartInfo.Arguments = "/c " & command
cmd.Start()
End Function
Public Shared Function pingip(ip As String, Optional ByVal Argument As String = "")
Dim ping As New Process
'ping.StartInfo.FileName = "cmd.exe"
@@ -67,35 +78,58 @@
End Function
Public Shared Function StartTeamviewer(ID As String, Optional Passwort As String = "BmWr501956")
Dim p As String = ""
If Passwort.Length < 1 Then
Passwort = "BmWr501956"
End If
If File.Exists("C:\Program Files (x86)\TeamViewer\Teamviewer.exe") Then
p = "C:\Program Files (x86)\TeamViewer"
Else
p = "C:\Program Files\TeamViewer"
End If
Dim teamviewer As New Process
With teamviewer.StartInfo
.FileName = "Teamviewer.exe"
.WorkingDirectory = "C:\Program Files (x86)\TeamViewer"
.WorkingDirectory = p
.Arguments = "-i " & ID & " -P " & Passwort
End With
teamviewer.Start()
Try
teamviewer.Start()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Public Shared Function RDPConnect(host As String, Optional ByVal Username As String = "", Optional ByVal Password As String = "")
Public Shared Function RDPConnect(host As String, Optional ByVal Username As String = "", Optional ByVal Password As String = "", Optional ByVal Fenster As Boolean = False)
Dim mstsc As New Process
Dim AnmeldeDatenVorhanden As Boolean = False
Dim rdpASadmin As String = ""
Dim FensterString As String = ""
If Fenster = True Then
FensterString = " /w:1280 /h:1024"
Else
FensterString = " /f"
End If
If host = "rdpintern.verag.ag" Then
commandcmd("cmdkey /delete:" & host)
commandcmd("cmdkey /delete:TERMSRV/" & host)
ElseIf host.StartsWith("TS") Then
rdpASadmin = " /admin"
End If
If Username.Length > 0 And Password.Length > 0 Then
Dim Anmeldung As New Process : AnmeldeDatenVorhanden = True
With Anmeldung
.StartInfo.FileName = Environment.ExpandEnvironmentVariables("%SystemRoot%\system32\cmdkey.exe")
.StartInfo.Arguments = "/add:TERMSRV/" & host & " /user:" & Username & " /pass:" & Password
.Start()
End With
AnmeldeDatenVorhanden = True
commandcmd("cmdkey /generic:" & host & " /user:" & Username & " /pass:" & Password)
End If
Threading.Thread.Sleep(1000)
mstsc.StartInfo.FileName = "mstsc.exe"
mstsc.StartInfo.UseShellExecute = False
mstsc.StartInfo.Arguments = " /v: " & host
mstsc.StartInfo.Arguments = " /v: " & host & rdpASadmin & FensterString
mstsc.Start()
@@ -103,11 +137,7 @@
Threading.Thread.Sleep(3000)
Dim Abmeldung As New Process
With Abmeldung
.StartInfo.FileName = Environment.ExpandEnvironmentVariables("%SystemRoot%\system32\cmdkey.exe")
.StartInfo.Arguments = "/delete:TERMSRV/" & host
End With
commandcmd("cmdkey /delete:" & host)
End If

View File

@@ -24,6 +24,7 @@ Public Class cHost
Property Firewall As Boolean = False
Property TeamviewerID As String = ""
Property TeamviewerKennwort As String = ""
Property SSHPort As Decimal = 22
@@ -54,6 +55,7 @@ Public Class cHost
list.Add(New SQLVariable("Firewall", Firewall))
list.Add(New SQLVariable("TeamviewerID", TeamviewerID))
list.Add(New SQLVariable("TeamviewerKennwort", TeamviewerKennwort))
list.Add(New SQLVariable("SSHPort", SSHPort))
Return list
End Function
@@ -83,6 +85,7 @@ Public Class cHost
list.Add(New SQLVariable("Firewall", Firewall))
list.Add(New SQLVariable("TeamviewerID", TeamviewerID))
list.Add(New SQLVariable("TeamviewerKennwort", TeamviewerKennwort))
list.Add(New SQLVariable("SSHPort", SSHPort))
Return list
End Function
@@ -111,6 +114,7 @@ Public Class cHost
Me.Firewall = False
Me.TeamviewerID = ""
Me.TeamviewerKennwort = ""
Me.SSHPort = 22
End Function
Public Shared Function getHostsEntrys(ByRef ds As DataSet, ByVal HostIP As String)
@@ -297,6 +301,7 @@ Diese Einträge werden ebenfalls gelöscht. Fortfahren?", "Hosteintrag löschen"
newhost.Standort = Me.Standort
newhost.DHCP = Me.DHCP
newhost.Firewall = Me.Firewall
newhost.SSHPort = Me.SSHPort
Dim update, where As String
getUpdateCmd(update, where, "", "", newhost.Linked, newhost)

View File

@@ -0,0 +1,123 @@
Imports System.Reflection
Imports Chilkat
Public Class cPascom
Dim API_USER_AUTHORIZATION = "bW9ieTpnWlhTSVprTnhmaUQxOEU="
Property Arbeitsplatz As String = ""
Property Username As String = ""
Public Function Anmelden() As Boolean
If Arbeitsplatz.Length > 0 And Username.Length > 0 Then
Try
'Benutzername: moby
'Passwort: XgDsFmMSutaMLA1
'BASIC Auth String: bW9ieTpYZ0RzRm1NU3V0YU1MQTE =
cChilkat_Helper.UnlockCilkat()
Dim API_STRING = "pbx3.flashnet.at"
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = rest.Connect(API_STRING, port, bTls, bAutoReconnect)
If (success <> True) Then
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
Debug.WriteLine(rest.LastErrorText)
Return False
End If
rest.AddHeader("Content-Type", "application/json")
rest.SetAuthBasic("moby", "XgDsFmMSutaMLA1")
Dim json As New Chilkat.JsonObject
Dim successJsonLoad As Boolean = json.Load("
{""action"":""relocate"",""username"":""" & Username & """}}")
If (successJsonLoad <> True) Then
MsgBox(json.LastErrorText)
Return False
End If
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
' MsgBox(sbRequestBody.ToString)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST", "/verag/services/location/" & Arbeitsplatz, sbRequestBody, sbResponseBody)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Return False
End If
Dim respStatusCode As Integer = rest.ResponseStatusCode
If (respStatusCode <> 202) Then
' MsgBox(sbResponseBody.GetAsString())
Return False
End If
Dim jsonResp = New Chilkat.JsonObject()
jsonResp.LoadSb(sbResponseBody)
Dim gatewayId = jsonResp.StringOf("gatewayId")
Dim Resp_error = jsonResp.StringOf("error")
Dim Resp_errorCode = jsonResp.StringOf("errorCode")
Return True
Catch ex As Exception
Return False
End Try
Return True
Else
Return False
End If
End Function
'Public Function GetTelArbeitsplatz4Host() As Boolean
' Try
' Dim lines = IO.File.ReadAllLines("\\dc01.verag.ost.dmn\NETLOGON\Telefonarbeitsplaetze.ini")
' Dim colCount = lines.First.Split(";"c).Length
' For Each line In lines
' Dim objFields = From field In line.Split(";"c)
' If String.Compare(cRes.LocalUser.Hostname, objFields(0).ToString, True) = 0 Then
' Arbeitsplatz = objFields(1).ToString
' '_ConString = objFields(2).ToString
' Return True
' Exit Function
' End If
' ' End Select
' Next
' Return False
' Catch ex As Exception
' ' MsgBox("Fehler beim Lesen TSAnmeldung.ini: " & vbCrLf & ex.Message)
' End Try
'End Function
End Class