Advertisement
Guest User

AutoPatcher.vbs

a guest
Mar 21st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Const adTypeBinary = 1
  2. Const adSaveCreateOverWrite = 2
  3. fileToModify = "Humans Must Answer.exe"
  4.  
  5. Set fso = CreateObject("Scripting.FileSystemObject")
  6. If Not (fso.FileExists(fileToModify)) Then
  7.     MsgBox "Unable to find " & Chr(34) & fileToModify & Chr(34) & ". This script must be placed in the game directory.", vbCritical
  8.     Wscript.Quit
  9. End If
  10.  
  11. If Not (fso.FileExists(fileToModify & ".bak")) Then
  12.     fso.CopyFile fileToModify, fileToModify & ".bak"
  13.     If Not (fso.FileExists(fileToModify & ".bak")) Then
  14.         result = MsgBox ("Unable to create backup " & Chr(34) & fileToModify & ".bak" & Chr(34) & ". Would you like to patch " & Chr(34) & fileToModify & Chr(34) & " anyway?", vbYesNo+vbExclamation)
  15.         If result = 7 Then
  16.             Wscript.Quit
  17.         End If
  18.     End If
  19. End If
  20.  
  21. Set stream = CreateObject("ADODB.Stream")
  22. stream.Open
  23. stream.Type = adTypeBinary
  24. stream.LoadFromFile fileToModify
  25. stream.Position = &H0014F479
  26. stream.Write BytesToBinaryArray(ChrB(&H16))
  27. stream.SaveToFile fileToModify, adSaveCreateOverWrite
  28. stream.Close()
  29.  
  30. Function BytesToBinaryArray(Bytes)
  31.     Set patch = CreateObject("ADODB.Stream")
  32.     patch.Open
  33.     patch.WriteText Bytes
  34.     patch.Position = 0
  35.     patch.Type = adTypeBinary
  36.     patch.Position = 2 ' Skip the BOM bytes
  37.     BytesToBinaryArray = patch.Read(LenB(Bytes))
  38.     patch.Close()
  39. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement