-
Notifications
You must be signed in to change notification settings - Fork 128
/
Bldg_Premium_Full.vbs
309 lines (227 loc) · 8.59 KB
/
Bldg_Premium_Full.vbs
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
'*******************************************************************************
' Author: Mick Pletcher
' Date: 20 November 2012
' Modified:
'
' Description: This will install Revit 2013
'*******************************************************************************
Option Explicit
REM Define Global Variables
DIM Architecture : Set Architecture = Nothing
DIM INIFile : INIFile = "bldg_premium_full_Relative.ini"
DIM InstallFile : InstallFile = "setup.exe"
DIM TempFolder : TempFolder = "c:\temp\"
DIM LogFolderName : LogFolderName = "bldg_premium_full"
DIM LogFolder : LogFolder = TempFolder & LogFolderName & "\"
DIM NewformaExist : NewformaExist = False
DIM RelativePath : Set RelativePath = Nothing
REM Define the relative installation path
DefineRelativePath()
REM Disable File Security Warning
DisableWarning()
REM Map Drive Letter
MapDrive()
REM Create the Log Folder
CreateLogFolder()
REM Install RAC
InstallRevit()
REM Enable File Security Warning
EnableWarning()
REM Cleanup Global Memory
GlobalMemoryCleanup()
'*******************************************************************************
'*******************************************************************************
Sub DefineRelativePath()
REM Get File Name with full relative path
RelativePath = WScript.ScriptFullName
REM Remove file name, leaving relative path only
RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))
End Sub
'*******************************************************************************
Sub MapDrive()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM DeleteDrive : DeleteDrive = "net use z: /delete /Y"
DIM MapDriveLetter : MapDriveLetter = "net use z:" & Chr(32) & Left(RelativePath, InStrRev(RelativePath, "\")-1)
oShell.Run DeleteDrive, 1, True
oShell.Run MapDriveLetter, 1, True
RelativePath = "z:\"
REM Cleanup Local Variables
Set DeleteDrive = Nothing
Set MapDriveLetter = Nothing
Set oShell = Nothing
End Sub
'*******************************************************************************
Sub CreateLogFolder()
REM Define Local Objects
DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
If NOT FSO.FolderExists(TempFolder) then
FSO.CreateFolder(TempFolder)
End If
If NOT FSO.FolderExists(LogFolder) then
FSO.CreateFolder(LogFolder)
End If
REM Cleanup Local Variables
Set FSO = Nothing
End Sub
'*******************************************************************************
Sub DetermineArchitecture()
REM Define Local Objects
DIM WshShell : Set WshShell = CreateObject("WScript.Shell")
REM Define Local Variables
DIM OSType : OSType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OSType = "x86" then
Architecture = "x86"
elseif OSType = "AMD64" then
Architecture = "x64"
end if
REM Cleanup Local Memory
Set WshShell = Nothing
Set OSType = Nothing
End Sub
'*******************************************************************************
Sub CheckFreeSpace()
REM Define Local Objects
DIM oShell : Set oShell = CreateObject( "WScript.Shell" )
REM Define Local Variables
DIM strComputer : strComputer = "."
DIM SystemDrive : SystemDrive = oShell.ExpandEnvironmentStrings("%SystemDrive%")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
If objDisk.DeviceID = SystemDrive then
Wscript.Echo "DeviceID: " & objDisk.DeviceID
Wscript.Echo "Free Disk Space: " _
& objDisk.FreeSpace
End If
Next
REM Cleanup Local Memory
Set oShell = Nothing
Set strComputer = Nothing
Set SystemDrive = Nothing
End Sub
'*******************************************************************************
Sub DisableWarning()
REM Define Local Objects
DIM oShell : Set oShell= CreateObject("Wscript.Shell")
DIM oEnv : Set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
REM Cleanup Memory
Set oShell = Nothing
Set oEnv = Nothing
End Sub
'*******************************************************************************
Sub EnableWarning()
REM Define Local Objects
DIM oShell : Set oShell= CreateObject("Wscript.Shell")
DIM oEnv : Set oEnv = oShell.Environment("PROCESS")
oEnv.Remove("SEE_MASK_NOZONECHECKS")
REM Cleanup Memory
Set oShell = Nothing
Set oEnv = Nothing
End Sub
'*******************************************************************************
Sub InstallCpp()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM Switches : Switches = Chr(32) & "/passive /uninstall /norestart /log" & Chr(32) & LogFolder & "InstallC++.log"
DIM Install : Install = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86_NEW.exe" & Switches
DIM NoWait : NoWait = False
DIM Wait : Wait = True
oShell.Run Install, 1, True
REM Cleanup Local Memory
Set Switches = Nothing
Set Install = Nothing
Set NoWait = Nothing
Set oShell = Nothing
Set Wait = Nothing
End Sub
'*******************************************************************************
Sub UninstallCpp()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM Switches : Switches = Chr(32) & "/passive /uninstall /norestart /log" & Chr(32) & LogFolder & "UninstallC++.log"
DIM Uninstall01 : Uninstall01 = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86.exe" & Switches
DIM Uninstall02 : Uninstall02 = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86_NEW.exe" & Switches
DIM NoWait : NoWait = False
DIM Wait : Wait = True
oShell.Run Uninstall01, 1, True
oShell.Run Uninstall02, 1, True
REM Cleanup Local Memory
Set Switches = Nothing
Set Uninstall01 = Nothing
Set Uninstall02 = Nothing
Set NoWait = Nothing
Set oShell = Nothing
Set Wait = Nothing
End Sub
'*******************************************************************************
Sub InstallRevit()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM Switches : Switches = Chr(32) & "/qb /I" & Chr(32) & RelativePath & "AdminImage\" & INIFile & Chr(32) & "/language en-us"
DIM Install : Install = RelativePath & "AdminImage\" & InstallFile & Switches
DIM NoWait : NoWait = False
DIM Wait : Wait = True
oShell.Run Install, 1, True
Call WaitForInstall()
REM Cleanup Local Variables
Set Install = Nothing
Set NoWait = Nothing
Set oShell = Nothing
Set Switches = Nothing
Set Wait = Nothing
End Sub
'*******************************************************************************
Sub WaitForInstall()
REM Define Local Constants
CONST Timeout = 3000
CONST Timepoll = 500
REM Define Local Variables
DIM sQuery : sQuery = "select * from win32_process where name=" & Chr(39) & InstallFile & Chr(39)
DIM SVC : Set SVC = GetObject("winmgmts:root\cimv2")
REM Define Local Variables
DIM cproc : Set cproc = Nothing
DIM iniproc : Set iniproc = Nothing
REM Wait until Second Setup.exe closes
Wscript.Sleep 30000
Set cproc = svc.execquery(sQuery)
iniproc = cproc.count
Do While iniproc = 1
wscript.sleep 5000
set svc=getobject("winmgmts:root\cimv2")
sQuery = "select * from win32_process where name=" & Chr(39) & InstallFile & Chr(39)
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Loop
REM Cleanup Local Variables
Set cproc = Nothing
Set iniproc = Nothing
Set sQuery = Nothing
set SVC = Nothing
End Sub
'*******************************************************************************
Sub GlobalMemoryCleanup()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM DeleteDrive : DeleteDrive = "net use z: /delete /Y"
oShell.Run DeleteDrive, 1, True
Set Architecture = Nothing
Set INIFile = Nothing
Set InstallFile = Nothing
Set LogFolder = Nothing
Set LogFolderName = Nothing
Set RelativePath = Nothing
Set TempFolder = Nothing
REM Cleanup Local Memory
Set DeleteDrive = Nothing
Set oShell = Nothing
End Sub