Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.59 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ' bootini.vbs -- modify the boot.ini, locate the DEP option, if set to OptOut
  2. ' change to AlwaysOff
  3. Const ForReading = 1
  4. Const ForWriting = 2
  5. Const conFileName = "boot.ini"
  6. Const strFindText = "/NoExecute=OptOut"
  7. Const strChangeText = "/NoExecute=AlwaysOff"
  8. Dim strFileName
  9.  
  10. On Error Resume Next
  11.  
  12. ' retrieve system drive variable from environment...
  13. Set objShell = CreateObject("WScript.Shell")
  14. strSystemDrive = objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
  15. ' WScript.Echo strSystemDrive
  16.  
  17. ' build file name...
  18. strFileName = strSystemDrive & "\" & conFileName
  19.  
  20. ' open the boot.ini file...
  21. Set objFSO = CreateObject("Scripting.FileSystemObject")
  22. ' Set objFile = objFSO.OpenTextFile(conFileName, ForReading)
  23. Set objFile = objFSO.OpenTextFile(strFileName, ForReading)
  24.  
  25. strNewText = ""
  26. strText = objFile.ReadAll
  27. objFile.Close
  28. intPos = InStr(1, strText, strFindText)
  29.  
  30. If intPos > 0 Then
  31. ' we have a match... make the change
  32. strNewText = Replace(strText, strFindText, strChangeText)
  33.  
  34. ' turn read only bit off
  35. x = ToggleArchiveBit ( strFileName )
  36.  
  37. ' open boot.ini file for update
  38. Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
  39. objFile.WriteLine strNewText
  40. objFile.Close
  41.  
  42. ' turn read only bit on
  43. x = ToggleArchiveBit ( strFileName )
  44. End If
  45.  
  46. Function ToggleArchiveBit(filespec)
  47. Dim fso, f
  48. Set fso = CreateObject("Scripting.FileSystemObject")
  49. Set f = fso.GetFile(filespec)
  50. If f.attributes and 1 Then
  51. f.attributes = f.attributes - 1
  52. ToggleArchiveBit = "Read bit is cleared."
  53. Else
  54. f.attributes = f.attributes + 1
  55. ToggleArchiveBit = "Read bit is set."
  56. End If
  57. End Function