-
Notifications
You must be signed in to change notification settings - Fork 0
/
AOOI4WIN.vbs
97 lines (83 loc) · 3.44 KB
/
AOOI4WIN.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
Set oShell = CreateObject("Wscript.Shell")
Set WshSysEnv = oShell.Environment("PROCESS")
sProcArch = WshSysEnv("PROCESSOR_ARCHITECTURE")
Wscript.Echo ("Atomic Offline OS Installer for Windows. Version 0.1" & vbCrLf & "Author: Scott R. Shinn <scott@atomicrocketturtle.com>" & vbCrLf & vbCrLf & "This installer will re-image your server with CentOS 5." & vbCrLf & "DHCP is required to complete the installation.")
Wscript.Echo "Turtle power."
Select Case sProcArch
Case "x86"
SourceURL1="http://www.atomicorp.com/installers/AOOI/i386/vmlinuz"
SourceURL2="http://www.atomicorp.com/installers/AOOI/i386/initrd.img"
Case "AMD64"
SourceURL1="http://www.atomicorp.com/installers/AOOI/x64_86/vmlinuz"
SourceURL2="http://www.atomicorp.com/installers/AOOI/x64_86/initrd.img"
Case "IA64"
SourceURL1="http://www.atomicorp.com/installers/AOOI/ia64/vmlinuz"
SourceURL2="http://www.atomicorp.com/installers/AOOI/ia64/initrd.img"
Case Else
Wscript.Echo "Cannot determine processor architecture|processor architecture not supported"
WScript.Quit
End Select
SourceURL3="http://www.atomicorp.com/installers/AOOI/win32/grubinst.exe"
SourceURL4="http://www.atomicorp.com/installers/AOOI/win32/grldr"
SourceURL5="http://www.atomicorp.com/installers/AOOI/win32/menu.lst"
TargetPath = "C:\vmlinuz"
SaveWebBinary SourceURL1,TargetPath
TargetPath = "C:\initrd.img"
SaveWebBinary SourceURL2,TargetPath
TargetPath = "C:\grubinst.exe"
SaveWebBinary SourceURL3,TargetPath
TargetPath = "C:\grldr"
SaveWebBinary SourceURL4,TargetPath
TargetPath = "C:\menu.lst"
SaveWebBinary SourceURL5,TargetPath
oShell.run "C:\grubinst.exe (hd0)"
Wscript.Echo ("Setup has successfully completed. Reboot your server to initiate the installation process" & vbCrLf & "The default root password will be set to: atomic555")
Function SaveWebBinary(strUrl, strFile) 'As Boolean
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const ForWriting = 2
Dim web, varByteArray, strData, strBuffer, lngCounter, ado
On Error Resume Next
'Download the file with any available object
Err.Clear
Set web = Nothing
Set web = CreateObject("WinHttp.WinHttpRequest.5.1")
If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "GET", strURL, False
web.Send
If Err.Number <> 0 Then
SaveWebBinary = False
Set web = Nothing
Exit Function
End If
If web.Status <> "200" Then
SaveWebBinary = False
Set web = Nothing
Exit Function
End If
varByteArray = web.ResponseBody
Set web = Nothing
'Now save the file with any available method
On Error Resume Next
Set ado = Nothing
Set ado = CreateObject("ADODB.Stream")
If ado Is Nothing Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(strFile, ForWriting, True)
strData = ""
strBuffer = ""
For lngCounter = 0 to UBound(varByteArray)
ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
Next
ts.Close
Else
ado.Type = adTypeBinary
ado.Open
ado.Write varByteArray
ado.SaveToFile strFile, adSaveCreateOverWrite
ado.Close
End If
SaveWebBinary = True
End Function