-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallSoftware.vb
175 lines (134 loc) · 5.95 KB
/
InstallSoftware.vb
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Imports System.ComponentModel
Imports System.Net
Public Class InstallSoftware
Dim installstep As Integer = 1
Sub installChocolatey()
powershellscript = "Set-ExecutionPolicy Bypass -Scope Process -Force; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex"
RunPowerShell()
End Sub
Sub InstallChocoApps()
RunCmd("@""%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"" -NoProfile -ExecutionPolicy Bypass -Command ""iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"" && SET ""PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin""", "", False, True)
Dim Packages() As String = {"zoom", "whatsapp", "pdfcreator", "bluebeamvu", "teamviewer"}
For Each p In Packages
Background_InstallSoftware.ReportProgress(10)
RunCmd("choco install " & p & " --force -y --no-progress", "", False, True)
installstep = installstep + 1
Next
End Sub
Sub RunCmd(command As String, arguments As String, permanent As Boolean, display As Boolean)
Try
Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
pi.Arguments = " " + If(permanent = True, "/K", "/C") + " " + command + " " + arguments
pi.FileName = "cmd.exe"
pi.WindowStyle = ProcessWindowStyle.Hidden
pi.CreateNoWindow = True
pi.Verb = "runas"
pi.UseShellExecute = False
p.StartInfo = pi
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start()
p.WaitForExit()
p.Close()
Catch ex As Exception
End Try
End Sub
Dim powershellscript As String
Sub RunPowerShell()
Try
Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
pi.Arguments = powershellscript
pi.FileName = "powershell.exe"
pi.WindowStyle = ProcessWindowStyle.Hidden
pi.CreateNoWindow = True
pi.Verb = "runas"
pi.UseShellExecute = False
p.StartInfo = pi
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start()
p.WaitForExit()
p.Close()
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
Background_Chocolatey.RunWorkerAsync()
End Sub
Private Sub Background_Chocolatey_DoWork(sender As Object, e As DoWorkEventArgs) Handles Background_Chocolatey.DoWork
installChocolatey()
End Sub
Private Sub Background_Chocolatey_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles Background_Chocolatey.RunWorkerCompleted
Label5.Text = "Pre-Requisites installed. Now installing required software....please be patient, this can take a while."
prerequisitecheckbox.Checked = True
ProgressBar1.Location = New Point(280, 259)
Background_InstallSoftware.RunWorkerAsync()
End Sub
Private Sub InstallSoftware_Load(sender As Object, e As EventArgs) Handles Me.Load
Label5.Text = "Installing Software"
Background_Chocolatey.RunWorkerAsync()
End Sub
Private Sub Background_InstallSoftware_DoWork(sender As Object, e As DoWorkEventArgs) Handles Background_InstallSoftware.DoWork
InstallChocoApps()
End Sub
Private Sub Background_InstallSoftware_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles Background_InstallSoftware.RunWorkerCompleted
teamviewercheckbox.Checked = True
Installskype()
End Sub
Private Sub Background_InstallSoftware_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles Background_InstallSoftware.ProgressChanged
If installstep < 2 Then
zoomcheckbox.Checked = True
ProgressBar1.Location = New Point(306, 283)
Else
If installstep = 2 Then
whatsappcheckbox.Checked = True
ProgressBar1.Location = New Point(312, 305)
Else
If installstep = 3 Then
pdfcreatorcheckbox.Checked = True
ProgressBar1.Location = New Point(313, 324)
Else
If installstep = 4 Then
bluebeamvucheckbox.Checked = True
ProgressBar1.Location = New Point(312, 347)
Else
If installstep = 5 Then
teamviewercheckbox.Checked = True
ProgressBar1.Location = New Point(372, 372)
End If
End If
End If
End If
End If
ProgressBar3.PerformStep()
End Sub
Private Sub InstallSkype()
Dim s As String
s = "msiexec.exe /qn /i ""C:\Zone6HelpDesk\SkypeForBusinessPlugin.msi"""
Shell(s, AppWinStyle.NormalFocus)
ProgressBar1.Location = New Point(327, 395)
skypeforbusinesscheckbox.Checked = True
InstallIE()
End Sub
Private Sub InstallIE()
RunCmd("C:\Zone6HelpDesk\AddShortcuts.bat", "", False, True)
ProgressBar1.Location = New Point(376, 418)
ieshortcutscheckbox.Checked = True
UnPinEdge()
End Sub
Sub UnPinEdge()
Dim s As String
s = "powershell.exe ""C:\Zone6helpdesk\Unpin.ps1"""
Shell(s, AppWinStyle.NormalFocus)
ProgressBar1.Location = New Point(334, 441)
unpinedgecheckbox.Checked = True
PINInternetExplorer()
End Sub
Private Sub PINInternetExplorer()
RunCmd("C:\Zone6HelpDesk\syspin.exe ""%PROGRAMFILES%\Internet Explorer\iexplore.exe"" 5386", "", False, True)
Label2.Text = "IE Pinned to Taskbar."
pinietaskbarcheckbox.Checked = True
End Sub
End Class