1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
Const SQLiteVersion = "1.0.20.0"
Const SQLiteVersion = "1.0.21.0"
Main
Sub Main()
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim GacPath
Dim oExec
GacPath = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\sdkInstallRootv2.0")
Set oExec = WshShell.Exec(GacPath & "\bin\gacutil.exe -u System.Data.SQLite")
Do While oExec.Status = 0
WScript.Sleep(100)
Loop
Set oExec = WshShell.Exec(GacPath & "\bin\gacutil.exe -if ..\System.Data.SQLite.DLL")
Do While oExec.Status = 0
WScript.Sleep(100)
Loop
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Dim myDir
myDir = fso.GetParentFolderName(WScript.ScriptFullName)
|
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
|
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
|
-
-
-
+
-
+
-
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
-
-
+
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
|
regFileContents = regFile.ReadAll()
regFileContents = Replace(regFileContents, "%REGROOT%", regRoot)
regFileContents = Replace(regFileContents, "%XMLPATH%", Replace(xmlPath, "\", "\\"))
genRegFile.Write(regFileContents)
genRegFile.Close()
regFile.Close()
Dim oExec
Set oExec = WshShell.Exec("regedit /s """ & myDir & "\SQLiteDesigner.gen.reg""")
Do While oExec.Status = 0
WScript.Sleep(100)
Loop
fso.DeleteFile(myDir & "\SQLiteDesigner.gen.reg")
Dim machineConfig
Dim machineConfigFile
Dim machineConfigPath
Dim machineConfig
machineConfigPath = fso.GetSpecialFolder(WindowsFolder).Path & "\Microsoft.NET\Framework\v2.0.50727\CONFIG"
machineConfigFile = fso.GetSpecialFolder(WindowsFolder).Path & "\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config"
Set machineConfigFile = fso.OpenTextFile(machineConfigPath & "\machine.config")
machineConfig = machineConfigFile.ReadAll()
machineConfigFile.Close()
Set machineConfig = CreateObject("Microsoft.XMLDOM")
machineConfig.load machineConfigFile
Dim n
Dim x
Dim xmlNode
Dim xmlParent
n = InStr(1, machineConfig, "System.Data.SQLite, Version=1", 1)
If (n = 0) Then
n = InStr(1, machineConfig, "</DbProviderFactories>", 1)
Set xmlNode = machineConfig.selectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=""System.Data.SQLite""]")
If xmlNode Is Nothing Then
Set xmlParent = machineConfig.selectSingleNode("configuration/system.data/DbProviderFactories")
If n > 0 Then
n = InStrRev(machineConfig, vbCrLf, n, 1)
Set xmlNode = machineConfig.createNode(1, "add", "")
If n > 0 Then
machineConfig = Left(machineConfig, n + 1) & " <add name=""SQLite Data Provider"" invariant=""System.Data.SQLite"" description="".Net Framework Data Provider for SQLite"" type=""System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=" & SQLiteVersion & ", Culture=neutral, PublicKeyToken=db937bc2d44ff139"" />" & vbCrLf & Mid(machineConfig, n + 2)
End If
End If
Else
n = n + 27
x = InStr(n, machineConfig, ",", 1)
xmlNode.attributes.setNamedItem(machineConfig.createAttribute("name"))
If x > 0 Then
machineConfig = Left(machineConfig, n) & SQLiteVersion & Mid(machineConfig, x)
End If
xmlNode.attributes.setNamedItem(machineConfig.createAttribute("invariant"))
xmlNode.attributes.setNamedItem(machineConfig.createAttribute("description"))
xmlNode.attributes.setNamedItem(machineConfig.createAttribute("type"))
xmlParent.appendChild xmlNode
End If
Set machineConfigFile = fso.CreateTextFile(machineConfigPath & "\machine.config", true)
machineConfigFile.Write(machineConfig)
machineConfigFile.Close()
xmlNode.attributes.getNamedItem("name").value = "SQLite Data Provider"
xmlNode.attributes.getNamedItem("invariant").value = "System.Data.SQLite"
xmlNode.attributes.getNamedItem("description").value = ".Net Framework Data Provider for SQLite"
xmlNode.attributes.getNamedItem("type").value = "System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=" & SQLiteVersion & ", Culture=neutral, PublicKeyToken=db937bc2d44ff139"
machineConfig.save machineConfigFile
End Sub
|