-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.vb
More file actions
133 lines (129 loc) · 5.15 KB
/
Form1.vb
File metadata and controls
133 lines (129 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Public Class TheApp
Public Function GetOSVersion() As String
'Where are we running?
Select Case Environment.OSVersion.Platform
Case PlatformID.Win32S
Return "Win3.1x"
Case PlatformID.Win32Windows
Select Case Environment.OSVersion.Version.Minor
Case 0
Return "Win95"
Case 10
Return "Win98"
Case 90
Return "WinME"
Case Else
Return "Unknown"
End Select
Case PlatformID.Win32NT
Select Case Environment.OSVersion.Version.Major
Case 3
Return "NT3.51"
Case 4
Return "NT4"
Case 5
Select Case _
Environment.OSVersion.Version.Minor
Case 0
Return "Win2000"
Case 1
Return "WinXP"
Case 2
Return "Win2003"
End Select
Case 6
Select Case _
Environment.OSVersion.Version.Minor
Case 0
Return "WinVista/2008"
Case 1
Return "Win7/2008R2"
Case 2
Return "Win8/2012"
Case 3
Return "Win8.1/2012R2+"
End Select
Case Else
Return "Unknown"
End Select
Case PlatformID.WinCE
Return "WinCE"
Case Else
Return "Unknown"
End Select
Return "Unknown"
End Function
Public OSVersion As String = GetOSVersion()
Private Sub TheApp_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SSHConfirmLabel.Image = My.Resources.ok.ToBitmap
SSHConfirmLabel.Text = "Ready."
UsernameBox.Enabled = True
UsernameLabel.Enabled = True
IPBox.Enabled = True
IPLabel.Enabled = True
NotifIcon.Icon = My.Resources.neticon
NotifIcon.Text = "SSHelper"
NotifIcon.Visible = True
End Sub
Private Sub IPBox_TextChanged(sender As Object, e As EventArgs) Handles IPBox.TextChanged
If IPBox.Text = String.Empty Then
ConnectButton.Enabled = False
CopyClipboardButton.Enabled = False
Else
ConnectButton.Enabled = True
CopyClipboardButton.Enabled = True
End If
End Sub
Private Sub ConnectButton_Click(sender As Object, e As EventArgs) Handles ConnectButton.Click
Dim User As String
Dim IP As String = IPBox.Text.ToString
Dim ExecLine As String
Dim sb As New System.Text.StringBuilder()
If Not UsernameBox.Text = String.Empty Then
User = UsernameBox.Text & "@"
Else
User = "root@"
End If
ExecLine = sb.Append("ssh").Append(" ").Append(User).Append(IP).ToString
Try
Shell(ExecLine, AppWinStyle.NormalFocus)
SSHConfirmLabel.Image = My.Resources.run.ToBitmap
SSHConfirmLabel.Text = "SSH instance started."
Catch
Dim Texty As String = "Error starting SSH."
SSHConfirmLabel.Image = My.Resources.warn.ToBitmap
'As we are using .NET Framework 2.0, we can be ran under older systems.
'So, why not flavor in some text messages?
Select Case OSVersion
Case "Win95"
Texty = "SSH ain't budging on 95!"
Case "Win98"
Texty = "Expected SSH to run on 98? Maybe with KernelEx..."
Case "WinME"
Texty = "SSH couldn't start on Windows Millenium."
Case "Win2000"
Texty = "Error starting SSH on Windows 2000."
Case "WinXP"
Texty = "Couldn't eXPerience SSH on Windows XP."
Case "Win2003"
Texty = "Error starting SSH on Windows Server 2003/XP x64."
End Select
SSHConfirmLabel.Text = Texty
End Try
End Sub
Private Sub CopyClipboardButton_Click(sender As Object, e As EventArgs) Handles CopyClipboardButton.Click
Dim User As String
Dim IP As String = IPBox.Text.ToString
Dim Output As String
Dim sb As New System.Text.StringBuilder()
If Not UsernameBox.Text = String.Empty Then
User = sb.Append(UsernameBox.Text).Append("@").ToString
Else
User = "root@"
End If
Output = sb.Append("ssh").Append(" ").Append(User).Append(IP).ToString
My.Computer.Clipboard.SetText(Output)
SSHConfirmLabel.Image = My.Resources.write.ToBitmap
SSHConfirmLabel.Text = "Copied command to clipboard."
End Sub
End Class