Replies: 1 comment
-
|
If it would be "unlinked" from the 'DEF' as you say - it would not make a default mct media then and that's the primary expectation of the option. Feel free to adjust it for your own personal use, but I can't accommodate your request.
Other files are beyond the scope of this script and what you expect to find in a windows iso. @echo off & title DIR2ISO
set ISODir="C:\ISO\Dir"
set Label=Windows
set Output="C:\ISO\%Label%.iso"
if not exist %ISODir% echo place the target ISO files in directory: %ISODir%
call :DIR2ISO %ISODir% %Output% %Label%
pause
exit /b
#:DIR2ISO:# [PARAMS]: "directory" "file.iso" [optional]"label"
set ^ #=$f0=[io.file]::ReadAllText($env:0); $0=($f0-split '#[:]DIR2ISO[:]' ,3)[1]; $1=$env:1-replace'([`@$])','`$1'; iex($0+$1)
set ^ #=& set "0=%~f0"& set 1=;DIR2ISO %*& powershell -nop -c "%#%"& exit /b %errorcode%
function DIR2ISO ($dir,$iso,$label='DVD_ROM') {if (!(test-path -Path $dir -pathtype Container)) {"[ERR] $dir"; return 1}; $code=@"
using System; using System.IO; using System.Runtime.Interop`Services; using System.Runtime.Interop`Services.ComTypes;
public class dir2iso {public int AveYo=2021; [Dll`Import("shlwapi",CharSet=CharSet.Unicode,PreserveSig=false)]
internal static extern void SHCreateStreamOnFileEx(string f,uint m,uint d,bool b,IStream r,out IStream s);
public static int Create(string file, ref object obj, int bs, int tb) { IStream dir=(IStream)obj, iso;
try {SHCreateStreamOnFileEx(file,0x1001,0x80,true,null,out iso);} catch(Exception e) {Console.WriteLine(e.Message); return 1;}
int d=tb>1024 ? 1024 : 1, pad=tb%d, block=bs*d, total=(tb-pad)/d, c=total>100 ? total/100 : total, i=1, MB=(bs/1024)*tb/1024;
Console.Write("\r\n{0,2}% {1}MB {2} DIR2ISO",0,MB,file); if (pad > 0) dir.CopyTo(iso, pad * block, Int`Ptr.Zero, Int`Ptr.Zero);
while (total-- > 0) {dir.CopyTo(iso, block, Int`Ptr.Zero, Int`Ptr.Zero); if (total % c == 0) {Console.Write("\r{0,2}%",i++);}}
iso.Commit(0); Console.WriteLine("\r{0,2}% {1}MB {2} DIR2ISO",100,MB,file); return 0;} }
"@; & { $cs = new-object CodeDom.Compiler.CompilerParameters; $cs.GenerateInMemory = 1 #:: ` used to silence ps eventlog
$compile = (new-object Microsoft.CSharp.CSharpCodeProvider).CompileAssemblyFromSource($cs, $code)
$BOOT = @(); $bootable = 0; $mbr_efi = @(0,0xEF); $images = @('boot\etfsboot.com','efi\microsoft\boot\efisys.bin') #:: _noprompt
if (test-path $(join-path $dir -child 'efi\boot\bootaa64.efi')) {$images[0] = 'arm64-detected-use-only-efi-mode'}
0,1|% { $bootimage = join-path $dir -child $images[$_]; if (test-path -Path $bootimage -pathtype Leaf) {
$bin = new-object -ComObject ADODB.Stream; $bin.Open(); $bin.Type = 1; $bin.LoadFromFile($bootimage)
$opt = new-object -ComObject IMAPI2FS.BootOptions;$opt.AssignBootImage($bin.psobject.BaseObject); $opt.PlatformId = $mbr_efi[$_]
$opt.Emulation = 0; $bootable = 1; $opt.Manufacturer = 'Microsoft'; $BOOT += $opt.psobject.BaseObject } }
$fsi = new-object -ComObject IMAPI2FS.MsftFileSystemImage; $fsi.FileSystemsToCreate = 4; $fsi.FreeMediaBlocks = 0
if ($bootable) {$fsi.BootImageOptionsArray = $BOOT}; $TREE = $fsi.Root; $TREE.AddTree($dir,$false); $fsi.VolumeName = $label
$obj = $fsi.CreateResultImage(); $ret = [dir2iso]::Create($iso,[ref]$obj.ImageStream,$obj.BlockSize,$obj.TotalBlocks) }
[GC]::Collect(); return $ret
} #:DIR2ISO:# export directory as (bootable) udf iso - lean and mean snippet by AveYo, 2021
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi and thanks for this software. I was wondering if it's possible to add custom files to the ISO.$OEM$ folder.
I think the script is already capable of adding files, like with the
In this case, I'd like my files to be placed in the root of the iso file, not
sources\$OEM$\For example, maybe some one needs to add a custom autounattend.xml in the root of the ISO.
EDIT: It would be good if this task would be "unlinked" from the 'DEF' stage. In other words: adding custom folder without adding:$OEM$ PID.txt EI.cfg auto.cmd unattend.xml.
Beta Was this translation helpful? Give feedback.
All reactions