Comment construire un fichier image CD ISO à partir de la ligne de commande windows?

dans un effort pour satisfaire "le test Joel" question #2 "Pouvez-vous faire une construction en une seule étape?", J'essaie de terminer un script de construction de candidat de version avec la création d'un CD iso à partir de la collection de fichiers recueillis et générés par le créateur d'installateur.

il semble qu'il y ait beaucoup de bons outils (beaucoup gratuits) là-bas qui vont créer ISOs, mais j'ai besoin de trouver un qui peut être exécuté en ligne de commande windows pour que je puisse l'intégrer dans le script de construction de NAnt qui est déclenché par Le Régulateur De Vitesse.

L'environnement de construction est:

  • Windows Server 2003
  • .NET 1.1 - 3.5 (application, nous sommes en train de créer est construit sur la 2.0)
  • NullSoft installateur (INS)
  • CruiseControl.net
  • NAnt

j'ai cherché sur google, mais pas de chance encore.

quelqu'un a une recommandation?

25
demandé sur Taryn 2008-10-22 00:12:53

8 réponses

essayez mkisofs. Il fait partie de la cdrecord projet.

16
répondu Andrew 2008-10-21 20:17:16

Blatant plug, mais je viens de sortir une version alpha D'une bibliothèque C# OpenSource qui peut créer des fichiers ISO. Ne s'intègre pas directement avec Nant, mais vous pourriez envelopper la bibliothèque pour y arriver. Theres un exemple d'application (ISOCreate) qui crée des ISOs à partir d'une structure de répertoire, mais cet exemple peut également vous aider à démarrer:

CDBuilder builder = new CDBuilder();
builder.UseJoliet = true;
builder.VolumeIdentifier = "A_SAMPLE_DISK";
builder.AddFile(@"Folder\Hello.txt", Encoding.ASCII.GetBytes("Hello World!"));
builder.Build(@"C:\temp\sample.iso");

. net DiscUtils (sur GitHub)

12
répondu festive_ken 2018-05-02 05:43:46

Obtenir mkisofs Télécharger ici il fait partie des Cdrtools. Disponible pour la plupart des plateformes. Useage exemples:

mkisofs -v -dvd-video -V "VOLUME_NAME" -o "c:\my movies\iso\movie.iso" "c:\my movies\dvd"
mkisofs -r -R -J -l -L -o image-file.iso c:\project\install
10
répondu Gerhard 2010-09-12 22:25:23

création D'un CD simple ISO

j'ai trouvé de manière significative plus facile d'approche, et il ne nécessite pas de Cygwin: CDBurnerXP

ce n'est pas vraiment annoncé sur le site, mais il comprend une édition en ligne de commande, comme cdbxpcmd.exe. Il y a aussi une partie de la documentation sur les options de ligne de commande.

D'intérêt particulier sont les -iso et -format options; utilisé quelque chose comme:

cdbxpcmd --burn-data -folder:input -iso:output.iso -format:iso -changefiledates

pour générer une ISO appelée output.iso à partir des fichiers dans le input dossier


Création d'un ISO Bootable

l'outil en ligne de commande ne semble pas vous permettre de faire un CD amorçable directement. Cependant, si vous savez que votre liste de fichiers ne va pas changer (c'est-à-dire seulement le contenu de ces fichiers), vous pouvez essayer ce qui suit (non testé):

  • charger la version GUI CDBurnerXP
  • Ajouter les fichiers de manière interactive
  • Sélectionnez Disc - > Burn Options...
  • configurer votre image d'amorçage
  • Sélectionnez Fichier->Enregistrer pour créer un fichier DXP (qui est CDBurnerXP compilation format)

Ensuite, vous pouvez utiliser la commande suivante

cdbxpcmd --burn-data -layout:mycompilation.dxp -iso:output.iso -format:iso
10
répondu kibibu 2016-08-26 01:47:57

si vous voulez être dépendant de Microsoft (ne pas installer de logiciel supplémentaire). Vous pouvez utiliser IMAPI, construire dans Windows pour brûler des images. Informations supplémentaires concernant le script IMAPI peut être trouvé dans MSDN

5
répondu Tamir 2008-11-06 09:11:54

j'ai utilisé magiciso, mais je ne l'ai pas testé en profondeur. (Je peux essayer certains des autres mentionnés ici après quelques tests) je fais d'abord un installateur (un seul fichier) puis juste un iso.

http://www.magiciso.com/

voici le résultat de ma lutte pour que cela fonctionne en python:

add_option = '-a'
add_option_value = installer_fullpath
response_option = '-py' # answer yes to all options 


# Get the tempfile name -- to resolve long name issue
# --> My file names were initially too long for MagicIso and it would choke
f_handle = tempfile.TemporaryFile(suffix='.iso', prefix='mi_', dir='.')
temp_filename = f_handle.name
f_handle.close() # File automatically deleted on close                                

args = (magiciso_exe_fullpath,temp_filename,response_option,add_option,add_option_value)

# log output to file
magiciso_con_f = open(MAGICISO_CON_LOG,'w')

magiciso_process = subprocess.Popen(args,stdout=magiciso_con_f,stderr=magiciso_con_f)
magiciso_process.wait()
2
répondu monkut 2008-10-22 09:18:49

j'utilise mkisofs.exe du kit d'installation de nLite ou BartPE, d'où j'ai aussi appris les paramètres requis pour construire un cd amorçable.

1
répondu alexandrul 2008-12-06 13:27:19

Powershell peut créer une ISO. L'exemple ci-dessous comprend une interface graphique. Crédit à http://blog.apps.id.au/?p=5321

# Author: Hrisan Dzhankardashliyski
# Date: 20/05/2015

# Inspiration from
#
#   http://blogs.msdn.com/b/opticalstorage/archive/2010/08/13/writing-optical-discs-using-imapi-2-in-powershell.aspx</a>
#
# and
#
#   http://tools.start-automating.com/Install-ExportISOCommand/</a>
#
# with help from
#
#   http://stackoverflow.com/a/9802807/223837</a>

$InputFolder = ""

function WriteIStreamToFile([__ComObject] $istream, [string] $fileName)
{
# NOTE: We cannot use [System.Runtime.InteropServices.ComTypes.IStream],
# since PowerShell apparently cannot convert an IStream COM object to this
# Powershell type.  (See <a href="http://stackoverflow.com/a/9037299/223837">http://stackoverflow.com/a/9037299/223837</a> for
# details.)
#
# It turns out that .NET/CLR _can_ do this conversion.
#
# That is the reason why method FileUtil.WriteIStreamToFile(), below,
# takes an object, and casts it to an IStream, instead of directly
# taking an IStream inputStream argument.

$cp = New-Object CodeDom.Compiler.CompilerParameters
$cp.CompilerOptions = "/unsafe"
$cp.WarningLevel = 4
$cp.TreatWarningsAsErrors = $true

Add-Type -CompilerParameters $cp -TypeDefinition @"
using System;
using System.IO;
using System.Runtime.InteropServices.ComTypes;

namespace My
{

public static class FileUtil {
public static void WriteIStreamToFile(object i, string fileName) {
IStream inputStream = i as IStream;
FileStream outputFileStream = File.OpenWrite(fileName);
int bytesRead = 0;
int offset = 0;
byte[] data;
do {
data = Read(inputStream, 2048, out bytesRead);
outputFileStream.Write(data, 0, bytesRead);
offset += bytesRead;
} while (bytesRead == 2048);
outputFileStream.Flush();
outputFileStream.Close();
}

unsafe static private byte[] Read(IStream stream, int toRead, out int read) {
byte[] buffer = new byte[toRead];
int bytesRead = 0;
int* ptr = &bytesRead;
stream.Read(buffer, toRead, (IntPtr)ptr);
read = bytesRead;
return buffer;
}
}

}
"@

[My.FileUtil]::WriteIStreamToFile($istream, $fileName)
}

# The Function defines the ISO parameturs and writes it to file
function createISO([string]$VolName,[string]$Folder,[bool]$IncludeRoot,[string]$ISOFile){

# Constants from <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364840.aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/aa364840.aspx</a>
$FsiFileSystemISO9660   = 1
$FsiFileSystemJoliet    = 2
$FsiFileSystemUDF      = 4

$fsi = New-Object -ComObject IMAPI2FS.MsftFileSystemImage

#$fsi.FileSystemsToCreate = $FsiFileSystemISO9660 + $FsiFileSystemJoliet

$fsi.FileSystemsToCreate = $FsiFileSystemUDF
#When FreeMediaBlocks is set to 0 it allows the ISO file to be with unlimited size
$fsi.FreeMediaBlocks = 0
$fsi.VolumeName = $VolName

$fsi.Root.AddTree($Folder, $IncludeRoot)

WriteIStreamToFile $fsi.CreateResultImage().ImageStream $ISOFile
}

Function Get-Folder($initialDirectory)

{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")

$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.rootfolder = "MyComputer"

if($foldername.ShowDialog() -eq "OK")
{
$folder += [string]$foldername.SelectedPath
}
return $folder
}

# Show an Open Folder Dialog and return the directory selected by the user.
function Read-FolderBrowserDialog([string]$Message, [string]$InitialDirectory, [switch]$NoNewFolderButton)
{
$browseForFolderOptions = 0
if ($NoNewFolderButton) { $browseForFolderOptions += 512 }
$app = New-Object -ComObject Shell.Application
$folder = $app.BrowseForFolder(0, $Message, $browseForFolderOptions, $InitialDirectory)
if ($folder) { $selectedDirectory = $folder.Self.Path }
else { $selectedDirectory = '' }
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($app) > $null
return $selectedDirectory
}

#Prompts the user to save the ISO file, if the files does not exists it will create it otherwise overwrite without prompt
Function Get-SaveFile($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
Out-Null

$SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
$SaveFileDialog.CreatePrompt = $false
$SaveFileDialog.OverwritePrompt = $false
$SaveFileDialog.initialDirectory = $initialDirectory
$SaveFileDialog.filter = "ISO files (*.iso)| *.iso"
$SaveFileDialog.ShowHelp = $true
$SaveFileDialog.ShowDialog() | Out-Null
$SaveFileDialog.filename
}

# Show message box popup and return the button clicked by the user.
function Read-MessageBoxDialog([string]$Message, [string]$WindowTitle, [System.Windows.Forms.MessageBoxButtons]$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]$Icon = [System.Windows.Forms.MessageBoxIcon]::None)
{
Add-Type -AssemblyName System.Windows.Forms
return [System.Windows.Forms.MessageBox]::Show($Message, $WindowTitle, $Buttons, $Icon)
}

# GUI interface for the PowerShell script
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")  #loading the necessary .net libraries (using void to suppress output)

$Form = New-Object System.Windows.Forms.Form    #creating the form (this will be the "primary" window)
$Form.Text = "ISO Creator Tool:"
$Form.Size = New-Object System.Drawing.Size(600,300)  #the size in px of the window length, height
$Form.FormBorderStyle = 'FixedDialog'
$Form.MaximizeBox = $false
$Form.MinimizeBox = $false

$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(20,20)
$objLabel.Size = New-Object System.Drawing.Size(120,20)
$objLabel.Text = "Please select a Folder:"
$Form.Controls.Add($objLabel)

$InputBox = New-Object System.Windows.Forms.TextBox
$InputBox.Location = New-Object System.Drawing.Size(150,20)
$InputBox.Size = New-Object System.Drawing.Size(300,20)
$InputBox.Enabled = $false
$Form.Controls.Add($InputBox)

$objLabel2 = New-Object System.Windows.Forms.Label
$objLabel2.Location = New-Object System.Drawing.Size(20,80)
$objLabel2.Size = New-Object System.Drawing.Size(120,20)
$objLabel2.Text = "ISO File Name:"
$Form.Controls.Add($objLabel2)

$InputBox2 = New-Object System.Windows.Forms.TextBox
$InputBox2.Location = New-Object System.Drawing.Size(150,80)
$InputBox2.Size = New-Object System.Drawing.Size(300,20)
$InputBox2.Enabled = $false
$Form.Controls.Add($InputBox2)

$objLabel3 = New-Object System.Windows.Forms.Label
$objLabel3.Location = New-Object System.Drawing.Size(20,50)
$objLabel3.Size = New-Object System.Drawing.Size(120,20)
$objLabel3.Text = "ISO Volume Name:"
$Form.Controls.Add($objLabel3)

$InputBox3 = New-Object System.Windows.Forms.TextBox
$InputBox3.Location = New-Object System.Drawing.Size(150,50)
$InputBox3.Size = New-Object System.Drawing.Size(150,20)
$Form.Controls.Add($InputBox3)

$objLabel4 = New-Object System.Windows.Forms.Label
$objLabel4.Location = New-Object System.Drawing.Size(20,120)
$objLabel4.Size = New-Object System.Drawing.Size(120,20)
$objLabel4.Text = "Status Msg:"
$Form.Controls.Add($objLabel4)

$InputBox4 = New-Object System.Windows.Forms.TextBox
$InputBox4.Location = New-Object System.Drawing.Size(150,120)
$InputBox4.Size = New-Object System.Drawing.Size(200,20)
$InputBox4.Enabled = $false
$InputBox4.Text = "Set ISO Parameters..."
$InputBox4.BackColor = "LimeGreen"
$Form.Controls.Add($InputBox4)

$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(470,20)
$Button.Size = New-Object System.Drawing.Size(80,20)
$Button.Text = "Browse"
$Button.Add_Click({
$InputBox.Text=Read-FolderBrowserDialog
$InputBox4.Text = "Set ISO Parameters..."

})
$Form.Controls.Add($Button)

$Button2 = New-Object System.Windows.Forms.Button
$Button2.Location = New-Object System.Drawing.Size(470,120)
$Button2.Size = New-Object System.Drawing.Size(80,80)
$Button2.Text = "CreateISO"
$Button2.Add_Click({

if(($InputBox.Text -eq "") -or ($InputBox3.Text -eq "")){
Read-MessageBoxDialog "You have to select folder and specify ISO Volume Name" "Error: No Parameters entered!"
} else{
$SaveDialog = Get-SaveFile
#If you click cancel when save file dialog is called
if ($SaveDialog -eq ""){
return
}
$InputBox2.Text= $SaveDialog
$InputBox2.Refresh()
if($checkBox1.Checked){
$includeRoot=$true
}
else{
$includeRoot=$false
}
$InputBox4.BackColor = "Red"
$InputBox4.Text = "Generating ISO File!"
$InputBox4.Refresh()
createISO $InputBox3.Text $InputBox.Text $includeRoot $InputBox2.Text
$InputBox4.BackColor = "LimeGreen"
$InputBox4.Text = "ISO Creation Finished!"
$InputBox4.Refresh()
}
})
$Form.Controls.Add($Button2)

$objLabel5 = New-Object System.Windows.Forms.Label
$objLabel5.Location = New-Object System.Drawing.Size(20,160)
$objLabel5.Size = New-Object System.Drawing.Size(280,20)
$objLabel5.Text = "Check the box if you want to include the top folder:"
$Form.Controls.Add($objLabel5)

$checkBox1 = New-Object System.Windows.Forms.CheckBox
$checkBox1.Location = New-Object System.Drawing.Size(300,156)
$Form.Controls.Add($checkBox1)

$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()
0
répondu KERR 2017-09-06 06:22:22