I am running AuoIt ver. 3.3.8.1
I looked around for ways to do this, but I haven't found anything yet. So, I just decided to take a wack at it for a project I'm working on. Here is the code that I have.
The script is supposed to be run from the bootable device. It can be a CD, DVD, or USB. The commands work if you run them from an elevated command prompt, but they do not work from the code I have listed here. I will continue to work on it, but any assistance is greatly appreciated. Also, hopefully someone else will find this useful. It only works in Windows Vista and newer. You would have to modify the Boot.ini in Windows XP.
I looked around for ways to do this, but I haven't found anything yet. So, I just decided to take a wack at it for a project I'm working on. Here is the code that I have.
[ autoit ]
#include #Include-Once #RequireAdmin Func _CreateBootEntry() Local $Drive Local $ScriptPath = @ScriptDir $Drive = StringRegExp($ScriptPath, "([[:alpha:]]:)", 1) Msgbox(4096, "Drive", $Drive[0]) RunWait("bcdedit.exe /create {USB} /d ""USB Boot""", "", @SW_HIDE) RunWait("bcdedit.exe /set {USB} ramdiskdidevice partition= " & $Drive[0], "", @SW_HIDE) RunWait("bcdedit.exe /set {USB} ramdiskdipath \boot\boot.sdi", "", @SW_HIDE) RunWait(@ComSpec & " /c bcdedit.exe /create /d ""USB Boot"" /application OSLOADER > C:\GUID", "", @SW_HIDE) $File = FileOpen("C:\GUID", 0) $CurrentConfig = FileOpen(@HomeDrive & "\CurrentConfig.xml", 1) $Contents = FileRead($File) $GUID = StringRegExp($Contents, "(\{.*\})", 1) FileWriteLine($CurrentConfig, "" & $GUID[0] & "") RunWait("bcdedit.exe /set " & $GUID[0] & " device ramdisk=[" & $Drive[0] & "]\sources\boot.wim,{USB}", "", @SW_HIDE) RunWait("bcdedit.exe /set " & $GUID[0] & " path \windows\system32\winload.exe", "", @SW_HIDE) RunWait("bcdedit.exe /set " & $GUID[0] & " osdevice ramdisk=[" & $Drive[0] & "]\sources\boot.wim,{USB}", "", @SW_HIDE) RunWait("bcdedit.exe /set " & $GUID[0] & " systemroot \windows", "", @SW_HIDE) RunWait("bcdedit.exe /set " & $GUID[0] & " winpe yes", "", @SW_HIDE) RunWait("bcdedit.exe /set " & $GUID[0] & " detecthal yes", "", @SW_HIDE) RunWait("bcdedit.exe /displayorder " & $GUID[0] & " /addlast", "", @SW_HIDE) RunWait("bcdedit.exe /bootsequence " & $GUID[0], "", @SW_HIDE) EndFunc
The script is supposed to be run from the bootable device. It can be a CD, DVD, or USB. The commands work if you run them from an elevated command prompt, but they do not work from the code I have listed here. I will continue to work on it, but any assistance is greatly appreciated. Also, hopefully someone else will find this useful. It only works in Windows Vista and newer. You would have to modify the Boot.ini in Windows XP.