-
Notifications
You must be signed in to change notification settings - Fork 4
/
Install-WebApp.wsf
189 lines (152 loc) · 7.2 KB
/
Install-WebApp.wsf
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
176
177
178
179
180
181
182
183
184
185
186
187
188
<job id="Install-WebApp">
<script language="VBScript" src="..\..\scripts\ZTIUtility.vbs"/>
<script language="VBScript">
' //----------------------------------------------------------------------------
' //
' // Solution: Richard's Deployment Script
' // File: Install-WebApp.wsf
' //
' // Purpose: This will install Web App Link
' //
' // Author: Richard Tracy
' //
' // Usage: cscript Install-WebApp.wsf [/WebAppURL:<URL>] [/debug:true]
' //
' //----------------------------------------------------------------------------
'//----------------------------------------------------------------------------
'// Global constant and variable declarations
'//----------------------------------------------------------------------------
Option Explicit
Dim iRetVal
'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------
'On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0
'//---------------------------------------------------------------------------
'// Function: ZTIProcess()
'//---------------------------------------------------------------------------
Function ZTIProcess()
Dim sVersion,sArch,sFile
Dim sInstallName, sInstallerPath
Dim sLogFolder,sLogName,sLogPath
Dim sPrefix
Dim sICOCopyPath,sREGRunPath
Dim oLink,sLink
Dim sProgramFilesx86Path,sSystemx86Path,sCapicomPath
'// Apply Architecture arguments:
'If no argument provided check for MDT/SCCM variable
'If no variable or argument is provided, defualt to x86
If oUtility.Arguments.Exists("arch") Then
sArch = LCase(oUtility.Arguments("arch"))
ElseIf oEnvironment.Exists("Architecture") Then
sArch = LCase(oEnvironment.Item("Architecture"))
Else
sArch = "x86"
End If
'// Apply EZTV URL Arguments:
If oUtility.Arguments.Exists("WebAppURL") Then
sLink = oUtility.Arguments("WebAppURL")
ElseIf oEnvironment.Exists("WebAppURL") Then
sLink = oEnvironment.Item("WebAppURL")
End If
'// Variables:
'// Change if needed
sVersion = "8.1.6"
sFile = "fdd.ico"
sInstallName = "WebApp Web Client"
sInstallerPath = oUtility.ScriptDir & "\Source\" & sFile
'// Build log path (incase not used in task sequence)
If oEnvironment.Exists("_SMSTSLogPath") Then
sLogFolder = oEnvironment.Item("_SMSTSLogPath") & "\AppLogs"
Else
sLogFolder = oEnv("TEMP") & "\AppLogs"
End If
oUtility.VerifyPathExists sLogFolder
sLogName = Replace(sInstallName & "_" & sVersion & "_" & sArch & ".log"," ","")
sLogPath = sLogFolder & "\" & sLogName
'// Start the process
oLogging.CreateEntry "Starting " & sInstallName & " (" & sVersion & ") " & sArch & " installation", LogTypeInfo
If not oFSO.FileExists(sInstallerPath) then
oLogging.CreateEntry sInstallerPath & " was not found, unable to install " & sInstallName & " (" & sVersion & ")", LogTypeError
ZTIProcess = Failure
Exit Function
End if
'// Disable Zone Checks
oEnv("SEE_MASK_NOZONECHECKS") = 1
'// copy exe
sICOCopyPath = oEnv("ALLUSERSPROFILE") & "\" & sInstallName
oUtility.VerifyPathExists sICOCopyPath
iRetVal = oUtility.RunWithHeartbeat("cmd.exe /c copy /y """ & sInstallerPath & """ """ & sICOCopyPath & "\" & sFile & """")
If (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
If sArch = "x64" then
sProgramFilesx86Path = oEnv("PROGRAMFILES(X86)")
sSystemx86Path = "SysWOW64"
Else
sProgramFilesx86Path = oEnv("PROGRAMFILES")
sSystemx86Path = "System32"
End If
' check if Capicom is installed
If oFSO.FileExists(sProgramFilesx86Path & "\Microsoft CAPICOM 2.1.0.2\Lib\X86\capicom.dll") Then
sCapicomPath = sProgramFilesx86Path & "\Microsoft CAPICOM 2.1.0.2\Lib\X86\capicom.dll"
'check if capicom.dll exists
ElseIf oFSO.FileExists(oEnv("SYSTEMROOT") & "\" & sSystemx86Path & "\capicom.dll") Then
sCapicomPath = oEnv("SYSTEMROOT") & "\" & sSystemx86Path & "\capicom.dll"
Else
oUtility.RunWithHeartbeat("cmd.exe /c copy /y """ & oUtility.ScriptDir & "\Source\capicom.dll"" """ & oEnv("SYSTEMROOT") & "\" & sSystemx86Path & "\capicom.dll"" ")
sCapicomPath = oEnv("SYSTEMROOT") & "\" & sSystemx86Path & "\capicom.dll"
End If
oUtility.RunWithHeartbeat(oEnv("SYSTEMROOT") & "\" & sSystemx86Path & "\regsvr32.exe /s """ & sCapicomPath & """")
'//Build installer
If sArch = "x64" then
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayIcon", sICOCopyPath & "\" & sFile, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayName", sInstallName, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayVersion", sVersion, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\UninstallString", "rmdir /s /q """ & sICOCopyPath& """" & _
" && del /s /q """ & oEnv("AllUsersDesktop") & "\" & sInstallName & ".lnk" & """" & _
" && reg delete ""HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & """ /f"
Else
oShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayIcon", sICOCopyPath & "\" & sFile, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayName", sInstallName, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\DisplayVersion", sVersion, "REG_SZ"
oShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & "\UninstallString", "rmdir /s /q """ & sICOCopyPath & """" & _
" && del /s /q """ & oEnv("AllUsersDesktop") & "\" & sInstallName & ".lnk" & """" & _
" && reg delete ""HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sInstallName & """ /f"
End If
if sLink <> "" Then
Set oLink = oShell.CreateShortcut(oShell.SpecialFolders("AllUsersDesktop") & "\" & sInstallName & ".lnk")
If sArch = "x64" then
oLink.TargetPath = oEnv("PROGRAMFILES") & "\Internet Explorer\iexplore.exe"
Else
oLink.TargetPath = oEnv("PROGRAMFILES(X86)") & "\Internet Explorer\iexplore.exe"
End If
oLink.IconLocation = sICOCopyPath & "\" & sFile
oLink.Arguments = sLink
oLink.Save
oLogging.CreateEntry "Shortcut """ & oShell.SpecialFolders("AllUsersDesktop") & "\" & sInstallName & ".lnk"" created.", LogTypeInfo
End If
Else
ZTIProcess = Failure
oLogging.CreateEntry sInstallName & " installation failed with exit code = " & iRetVal, LogTypeError
End If
oLogging.CreateEntry "Finished " & sInstallName & " installation", LogTypeInfo
'// Enable Zone Checks
oEnv.Remove("SEE_MASK_NOZONECHECKS")
End Function
Function DeleteFile(sPath, sName)
On error resume next
Dim strFullPath
strFullPath = sPath & "\" & sName
If oFSO.fileexists(strFullPath) Then
oLogging.CreateEntry "File Found: " & strFullPath, LogTypeInfo
oFSO.DeleteFile strFullPath,0
oLogging.CreateEntry "File Deleted: " & strFullPath, LogTypeInfo
Else
oLogging.CreateEntry "File Not Found: " & strFullPath & ", skipping", LogTypeInfo
End If
End Function
</script>
</job>