Skip to content

Instantly share code, notes, and snippets.

@dougm
Created June 19, 2010 06:33
Show Gist options
  • Save dougm/444635 to your computer and use it in GitHub Desktop.
Save dougm/444635 to your computer and use it in GitHub Desktop.
REM cscript /nologo chef-client-bootstrap.vbs
Exe = "rubyinstaller-1.8.7-p249-rc2.exe"
Url = "http://rubyforge.org/frs/download.php/69034/" & Exe
Dst = "C:\Ruby"
Set Shell = CreateObject("WScript.Shell")
Set Fs = CreateObject("Scripting.FileSystemObject")
If Fs.FileExists(Exe) Then
WScript.Echo "Using existing " & Exe
Else
WScript.Echo "Downloading " & Url
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
Http.Open "GET", Url, False
Http.Send
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.Write Http.ResponseBody
BinaryStream.SaveToFile Exe, 2
BinaryStream.Close
End If
Ruby = Dst & "\bin\ruby.exe"
If Fs.FileExists(Ruby) Then
WScript.Echo Dst & " exists"
Else
WScript.Echo "Installing " & Exe & " to " & Dst
Cmd = Exe & " /dir=" & Dst & " /verysilent /tasks=assocfiles,modpath"
WScript.Echo Cmd
Set Exec = Shell.Exec(Cmd)
Do Until Exec.StdOut.AtEndOfStream
Line = Exec.StdOut.ReadLine()
Wscript.Echo Line
Loop
End If
Cmd = Ruby & " " & Dst & "\bin\gem install --no-ri --no-rdoc chef ruby-wmi windows-pr"
WScript.Echo Cmd
Set Exec = Shell.Exec(Cmd)
Do Until Exec.StdOut.AtEndOfStream
Line = Exec.StdOut.ReadLine()
Wscript.Echo Line
Loop
REM todo: chef client config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment