-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathTrimbleSketchupInstaller.vbs
More file actions
191 lines (145 loc) · 6.5 KB
/
Copy pathTrimbleSketchupInstaller.vbs
File metadata and controls
191 lines (145 loc) · 6.5 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
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
'*******************************************************************************
' Program: Install.vbs
' Author: Mick Pletcher
' Date: 24 July 2012
' Modified:
'
' Program: Trimble Sketchup
' Version: 8
' Description: This will install Sketchup with a network license
' 1) Define the relative installation path
' 2) Create the Log Folder
' 3) Check if Sketchup is already installed
' 3) Install
' 4) Copy Network License File
' 5) Cleanup Global Variables
'*******************************************************************************
Option Explicit
REM Define Constants
CONST TempFolder = "c:\temp\"
CONST LogFolderName = "Sketchup"
REM Define Global Variables
DIM Architecture : Set Architecture = Nothing
DIM RegKeyx86 : RegKeyx86 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88A47643-0A80-4FA8-A568-E9A63AAA98F4}"
DIM RegKeyx64 : RegKeyx64 = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{88A47643-0A80-4FA8-A568-E9A63AAA98F4}"
DIM LogFolder : LogFolder = TempFolder & LogFolderName & "\"
DIM RelativePath : Set RelativePath = Nothing
If NOT RegKeyExists("HKLM", RegKeyx86, "DisplayName") or NOT RegKeyExists("HKLM", RegKeyx64, "DisplayName") then
REM Define the relative installation path
DefineRelativePath()
REM Create the Log Folder
CreateLogFolder()
REM Determine OS Architecture
DetermineArchitecture()
REM Install
Install()
REM Copy Network License File
CopyLicenseFile()
End If
REM Cleanup Global Variables
GlobalVariableCleanup()
'*******************************************************************************
'*******************************************************************************
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 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 Memory
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 Memory
Set OSType = Nothing
End Sub
'*******************************************************************************
Sub Install()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM MSI : MSI = Chr(32) & RelativePath & "GoogleSketchUp8.msi"
DIM Logs : Logs = Chr(32) & "/lvx" & Chr(32) & LogFolder & LogFolderName & ".log"
DIM Transform : Transform = Chr(32) & "TRANSFORMS=" & RelativePath & "transform.mst"
DIM Parameters : Parameters = Chr(32) & "/qb- /norestart INSTALLGOOGLETOOLBAR=0 LicenseAccepted=1"
DIM Install : Install = "msiexec.exe /i" & MSI & Logs & Parameters
oShell.Run Install, 1, True
REM Cleanup Memory
Set Install = Nothing
Set Logs = Nothing
Set MSI = Nothing
Set oShell = Nothing
Set Parameters = Nothing
Set Transform = Nothing
End Sub
'*******************************************************************************
Sub CopyLicenseFile()
REM Define Local Objects
DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
If Architecture = "x86" then
FSO.CopyFile "\\global.gsp\data\clients\na_clients\Trimble\Sketchup\server.dat", "C:\Program Files\Google\Google SketchUp 8\server.dat", True
ElseIf Architecture = "x64" then
FSO.CopyFile "\\global.gsp\data\clients\na_clients\Trimble\Sketchup\server.dat", "C:\Program Files (x86)\Google\Google SketchUp 8\server.dat", True
End If
REM Cleanup Memory
Set FSO = Nothing
End Sub
'*******************************************************************************
Function RegKeyExists(nHive, strPath, strValueName)
Select Case Left(nHive, 20)
Case "HKCR", "HKEY_CLASSES_ROOT"
nHive = &H80000000
Case "HKCU", "HKEY_CURRENT_USER"
nHive = &H80000001
Case "HKLM", "HKEY_LOCAL_MACHINE"
nHive = &H80000002
Case "HKU", "HKEY_USERS"
nHive = &H80000003
Case "HKCC", "HKEY_CURRENT_CONFIG"
nHive = &H80000005
Case Else
WScript.Echo "Hive Not Supported."
GlobalVariableCleanup()
WScript.Quit
End Select
REM Define Local Constants
CONST strComputer = "."
REM Define Local Objects
DIM objRegistry : Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
REM Define Local Variables
DIM strValue : Set strValue = Nothing
objRegistry.GetStringValue nHive, strPath, strValueName, strValue
RegKeyExists = Not IsNull(strValue)
RegKeyExists = CStr (RegKeyExists)
REM Cleanup Local Memory
Set objRegistry = Nothing
Set strValue = Nothing
End Function
'*******************************************************************************
Sub GlobalVariableCleanup()
Set Architecture = Nothing
Set LogFolder = Nothing
Set RegKeyx86 = Nothing
Set RegKeyx64 = Nothing
Set RelativePath = Nothing
End Sub