Batch Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Répondre au sujet Page 2 sur 2
Aller à la page: <  1, 2
[Terminer] CloneVDIManager
Auteur Message
Répondre en citant
Message [Terminer] CloneVDIManager 
Revue du message précédent :

Merci MultiUser ;D


J essaie d avoir des projets intéressants pour motiver y a pas mieux ;D

Visiter le site web du posteur
Message Publicité 
PublicitéSupprimer les publicités ?


Répondre en citant
Message [Terminer] CloneVDIManager 
Ajout de la fonction pour créer la machine Virtuelle mais pour le moment ça bogue.
Soucis sur la commande RunWait.


Code:

#cs
   CloneVDI Manager v1.1 By Laddy
   CloneVDI Manager Projet commun 01 - Batch.xoo.it
   Cheffe de Projet : Laddy

   Pour les personnes voulant participées me contacter par MP.

#ce


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Opt("GUIOnEventMode", 1)
Global $String1, $String2, $String3, $IniDestination, $IniSource, $ClonageHD, $Annuler, $Progess1, $Creer, $BrowseDestination, $BrowseSource, $Cloner, $GuiCreateVM
Global $NameNewVM, $PathDir, $MemoryRAM, $VDI, $OS
Local $Progress1, $pid, $pourcent, $total

#Region ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf
$GuiCloneVDI = GUICreate("CloneVDIManager", 588, 356, 506, 332)
GUISetOnEvent($GUI_EVENT_CLOSE, "Sortie")
$Group1 = GUICtrlCreateGroup("Fichiers", 16, 16, 553, 113)
$Source = GUICtrlCreateLabel("Source :", 32, 48, 44, 17)
$Destination = GUICtrlCreateLabel("Destination : ", 32, 88, 66, 17)
$SourceFile = GUICtrlCreateInput("", 120, 48, 369, 21)
$DestinationFile = GUICtrlCreateInput("", 120, 88, 369, 21)
$BrowseSource = GUICtrlCreateButton("Parcourir...", 496, 48, 65, 25)
GUICtrlSetOnEvent($BrowseSource, "BrowseSrc")
$BrowseDestination = GUICtrlCreateButton("Parcourir...", 496, 88, 67, 25)
GUICtrlSetOnEvent($BrowseDestination, "BrowseDst")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Informations Source", 16, 136, 553, 105)
$Label4 = GUICtrlCreateLabel("UUID", 72, 160, 31, 17)
$UUID = GUICtrlCreateInput("", 128, 160, 361, 21)
$Label5 = GUICtrlCreateLabel("Taille du disque", 24, 200, 78, 17)
$SizeHD = GUICtrlCreateInput("", 128, 192, 161, 21)
$Label6 = GUICtrlCreateLabel("Accessibilite", 304, 200, 62, 17)
$Valid = GUICtrlCreateInput("", 376, 192, 177, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("A propos", 16, 256, 553, 49)
$Infos = GUICtrlCreateLabel("CloneVDIManager - Laddy -Cheffe de projet", 178, 271, 210, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Creer = GUICtrlCreateButton("Creer", 24, 312, 75, 25)
GUICtrlSetOnEvent($Creer, "CreateVM")
$Cloner = GUICtrlCreateButton("Cloner", 400, 312, 89, 25)
GUICtrlSetOnEvent($Cloner, "ClonageHD")
$Quitter = GUICtrlCreateButton("Quitter", 496, 312, 75, 25)
GUICtrlSetOnEvent($Quitter, "Sortie")
GUISetState(@SW_SHOW, $GuiCloneVDI)
#EndRegion ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf

;Variable
Global $SunVirtualBox = RegRead("HKEY_LOCAL_MACHINE\Software\Sun\VirtualBox", "InstallDir")
Global $OracleVirtualBox = RegRead("HKEY_LOCAL_MACHINE\Software\Oracle\VirtualBox", "InstallDir")


Do
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $BrowseSource
         BrowseSrc()
      Case $BrowseDestination
         BrowseDst()
      Case $Creer
         CreateVM()
      Case $Cloner
         ClonageHD()
      Case $Quitter
         Exit
   EndSwitch
Until $nMsg = $GUI_EVENT_CLOSE


Func CreateVM()
   ;ID créer une Gui.
   #Region ### START Koda GUI section ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\GuiCreateVM.kxf
   Global $GuiCreateVM = GUICreate("GuiCreateVM", 505, 257, 190, 121)
   Global $PathDir = GUICtrlCreateInput("PathDir", 96, 56, 385, 21)
   Global $VDI = GUICtrlCreateInput("VDI", 96, 96, 385, 21)
   Global $Go = GUICtrlCreateButton("Go", 408, 192, 75, 25)
   GUICtrlSetOnEvent($Go, "GoCreate")
   Global $Label1 = GUICtrlCreateLabel("Dossier :", 24, 56, 45, 17)
   Global $Label2 = GUICtrlCreateLabel("Image VDI", 24, 96, 54, 17)
   Global $MemoryRAM = GUICtrlCreateInput("MemoryRAM", 96, 136, 105, 21)
   Global $Memoire = GUICtrlCreateLabel("Memoire RAM :", 8, 144, 77, 17)
   Global $NameNewVM = GUICtrlCreateInput("NameVM", 96, 16, 121, 21)
   Global $Label3 = GUICtrlCreateLabel("Nom de la VM : ", 8, 16, 80, 17)
   Global $Label4 = GUICtrlCreateLabel("MB", 208, 144, 20, 17)
   Global $OS = GUICtrlCreateInput("OS", 360, 16, 121, 21)
   Global $Label5 = GUICtrlCreateLabel("OS Type :", 296, 16, 52, 17)
   GUISetState(@SW_SHOW, $GuiCreateVM)
   #EndRegion ### END Koda GUI section ###
EndFunc   ;==>CreateVM

Func GoCreate()
   ;note OStype est accessible via vboxmanage list Ostypes
   ;Exemple
   #cs
   ID:          WindowsXP
   Description: Windows XP

   ID:          Windows7
    Description: Windows 7
   #ce
   ;command de création Nom de la VM - Non testé VBoxManage storagectl "Windows XP" --name "IDE Controller" --add ide --controller PIIX4
   RunWait(@ComSpec & ' /c "' & $SunVirtualBox & 'VBoxManage.exe"' & " createvm --name " & GUICtrlRead($NameNewVM) & " --ostype " &GUICtrlRead($OS) & " --basefolder " & GUICtrlRead($PathDir) & " --register", "", @SW_HIDE) ;fichier bien crée dans le dossier indiqué
   RunWait(@ComSpec & ' /c "' & $SunVirtualBox & 'VBoxManage.exe"' & " modifyvm --name " & GUICtrlRead($NameNewVM) & " --memory " &GUICtrlRead($MemoryRAM), "", @SW_HIDE) ; memoire non prise en compte
   RunWait(@ComSpec & ' /c "' & $SunVirtualBox & 'VBoxManage.exe"' & " storagectl " & GUICtrlRead($NameNewVM) & ' -- name "IDE Controller" --add ide --controller PIIX4' , "", @SW_HIDE)
   RunWait(@ComSpec & ' /c "' & $SunVirtualBox & 'VBoxManage.exe"' & " storageattach " & GUICtrlRead($NameNewVM) & " --storagectl " & '"IDE Controller"' & " --port 0 --device 0 --type hdd --medium " & GUICtrlRead($VDI), "", @SW_HIDE) ;vdi non attaché
   KillGui3()
EndFunc   ;==>GoCreate




Func BrowseSrc()
   Local $ListInfo = "InfoSourceVDI.txt"
   Local $message = "Selectionne la source de ton fichier VDI."
   Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers VirtualBox (*.vdi;*.vmdk)", 1)
   GUICtrlSetData($SourceFile, $var)
   IniWrite(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", GUICtrlRead($SourceFile))
   $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
   FileChangeDir(@ScriptDir)
   RunWait(@ComSpec & ' /c "' & $SunVirtualBox & 'VBoxManage.exe"' & " showhdinfo " & $IniSource & " > " & $ListInfo, "", @SW_HIDE)
   $file = FileOpen("InfoSourceVDI.txt", 0)
   While 1
      $Line = FileReadLine($file)
      If @error Then ExitLoop
      If StringLeft($Line, 5) = "UUID:" Then $String1 = StringTrimLeft($Line, 6)
      If StringLeft($Line, 11) = "Accessible:" Then $String2 = StringTrimLeft($Line, 22)
      If StringLeft($Line, 13) = "Logical size:" Then $String3 = StringTrimLeft($Line, 14)
   WEnd
   FileClose($file)
   GUICtrlSetData($UUID, $String1)
   If StringUpper($String2) = "yes" Then
      GUICtrlSetColor($Valid, 0x00ff00) ; green
      GUICtrlSetData($Valid, $String2)
   Else
      GUICtrlSetColor($Valid, 0xff0000) ; Red
      GUICtrlSetData($Valid, $String2)
   EndIf
   GUICtrlSetData($SizeHD, Mo_To_Go($String3) & " Go")
EndFunc   ;==>BrowseSrc

Func BrowseDst()
   Local $message = "Sélectionne la destination de ton fichier VDI."
   Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers (*.vdi)")
   GUICtrlSetData($DestinationFile, $var)
   IniWrite(@DesktopDir & "\CloneVDIinfo.ini", "parametres", "Destination", GUICtrlRead($DestinationFile))
   $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
EndFunc   ;==>BrowseDst

Func Mo_To_Go($mo, $decimal = 3)
   Return Round($mo / 1024, $decimal)
EndFunc   ;==>Mo_To_Go

Func ClonageHD()
   #Region ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf
   $ClonageHD = GUICreate("Clonage Disque Virtuel", 306, 135, 192, 124)
   $Group1 = GUICtrlCreateGroup("En Cours", 8, 8, 289, 73)
   $Progress1 = GUICtrlCreateProgress(16, 40, 265, 17)
   GUICtrlCreateGroup("", -99, -99, 1, 1)
   $Annuler = GUICtrlCreateButton("Annuler", 208, 96, 81, 25)
   GUICtrlSetOnEvent($Annuler, "Annuler")
   GUISetState(@SW_SHOW, $ClonageHD)
   #EndRegion ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf


   #Region ### Action de clonage
   $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
   $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
   $pid = Run($SunVirtualBox & 'VBoxManage.exe clonehd "' & $IniSource & '" "' & $IniDestination & '"', $SunVirtualBox, @SW_HIDE)
   $total = FileGetSize($IniSource) ; ici il faudra mettre la taille du fichier source qui se fera clôner
   AdlibRegister("Update_progress", 1000)
   #EndRegion ### Action de clonage


EndFunc   ;==>ClonageHD

Func Annuler()
   $Choix = MsgBox(2, "Annuler par l'utilisateur", "Annuler ?")
   Switch $Choix
      Case 3
         ProcessClose($pid)
         ProcessClose("vboxSVC.exe")
         KillGui2()
      Case 4
      Case 5
   EndSwitch
EndFunc   ;==>Annuler


Func KillGui2() ; *****
   GUIDelete($ClonageHD) ; *****
EndFunc   ;==>KillGui2

Func KillGui3() ; *****
   GUIDelete($GuiCreateVM) ; *****
EndFunc   ;==>KillGui3

Func Sortie() ; *****
   If @GUI_WinHandle = $GuiCloneVDI Then ; *****
      Exit ; *****
   Else ; *****
      GUIDelete(@GUI_WinHandle) ; *****
   EndIf ; *****
EndFunc   ;==>Sortie

#Region ### fonction pour la progressbar
Func Update_progress()
   $pourcent = Int(FileGetSize($IniDestination) / $total * 100) ; calcul de la taille Destination en fonction de la source
   ConsoleWrite($pourcent & @CRLF)
   GUICtrlSetData($Progress1, $pourcent)
   If Not ProcessExists($pid) Then
      GUICtrlSetData($Progress1, 100)
      MsgBox("0", "Terminer", "Clonage Terminé")
      AdlibUnRegister("Update_progress")
      KillGui2()
   EndIf
EndFunc   ;==>Update_progress
#EndRegion ### fonction pour la progressbar





______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Répondre en citant
Message [Terminer] CloneVDIManager 
Voila ça fonctionne :





Code:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#cs
   CloneVDI Manager v1.1 By Laddy
   Cheffe de Projet : Laddy

   Command Line VboxManager :http://www.virtualbox.org/manual/ch08.html
   http://www.virtualbox.org/manual/ch08.html#vboxmanage-showvminfo
   http://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi
   http://www.virtualbox.org/manual/ch08.html#id494539 (vboxmanage-createvm)
   http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm
   http://www.virtualbox.org/manual/ch08.html#id508609 (VBoxManage.exe storageattach)
   http://www.virtualbox.org/manual/ch08.html#vboxmanage-storagectl

   Merci à l'ensemble des membres et équipes de Autoscript.fr The Forum pour leurs patiences et explications.
#ce
Opt("GUIOnEventMode", 1)
Global $String1, $String2, $String3, $IniDestination, $IniSource, $ClonageHD, $Annuler, $Progess1, $Creer, $BrowseDestination, $BrowseSource, $Cloner, $GuiCreateVM
Global $NameNewVM, $PathDir, $MemoryRAM, $VDI, $OS, $OSarch, $ListOsType, $OsType
Local $Progress1, $pid, $pourcent, $total

#Region ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf
$GuiCloneVDI = GUICreate("CloneVDIManager", 588, 356, 506, 332)
GUISetOnEvent($GUI_EVENT_CLOSE, "Sortie")
$Group1 = GUICtrlCreateGroup("Fichiers", 16, 16, 553, 113)
$Source = GUICtrlCreateLabel("Source :", 32, 48, 44, 17)
$Destination = GUICtrlCreateLabel("Destination : ", 32, 88, 66, 17)
$SourceFile = GUICtrlCreateInput("", 120, 48, 369, 21)
$DestinationFile = GUICtrlCreateInput("", 120, 88, 369, 21)
$BrowseSource = GUICtrlCreateButton("Parcourir...", 496, 48, 65, 25)
GUICtrlSetOnEvent($BrowseSource, "BrowseSrc")
$BrowseDestination = GUICtrlCreateButton("Parcourir...", 496, 88, 67, 25)
GUICtrlSetOnEvent($BrowseDestination, "BrowseDst")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Informations Source", 16, 136, 553, 105)
$Label4 = GUICtrlCreateLabel("UUID", 72, 160, 31, 17)
$UUID = GUICtrlCreateInput("", 128, 160, 361, 21)
$Label5 = GUICtrlCreateLabel("Taille du disque", 24, 200, 78, 17)
$SizeHD = GUICtrlCreateInput("", 128, 192, 161, 21)
$Label6 = GUICtrlCreateLabel("Accessibilite", 304, 200, 62, 17)
$Valid = GUICtrlCreateInput("", 376, 192, 177, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("A propos", 16, 256, 553, 49)
$Infos = GUICtrlCreateLabel("CloneVDIManager - Laddy -Cheffe de projet", 178, 271, 210, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Creer = GUICtrlCreateButton("Creer", 24, 312, 75, 25)
GUICtrlSetOnEvent($Creer, "CreateVM")
$Cloner = GUICtrlCreateButton("Cloner", 400, 312, 89, 25)
GUICtrlSetOnEvent($Cloner, "ClonageHD")
$Quitter = GUICtrlCreateButton("Quitter", 496, 312, 75, 25)
GUICtrlSetOnEvent($Quitter, "Sortie")
GUISetState(@SW_SHOW, $GuiCloneVDI)
#EndRegion ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf

;Variable
If @OSArch = "X64" Then $OSarch = "64"
;If StringRight($vbox_path, 1) = "\" Then $vbox_path = StringRegExpReplace($vbox_path, "\\$", "")

If RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Oracle\VirtualBox", "InstallDir") Then
   $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Oracle\VirtualBox", "InstallDir")
ElseIf RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\VirtualBox", "InstallDir") Then
   $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\VirtualBox", "InstallDir")
ElseIf RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\xVM VirtualBox", "InstallDir") Then
   $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\xVM VirtualBox", "InstallDir")
Else
   MsgBox(16, "VirtualBox", "Erreur d'installation ou le logiciel n'est pas installé sur ce poste.")
   Exit
EndIf

Do
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $BrowseSource
         BrowseSrc()
      Case $BrowseDestination
         BrowseDst()
      Case $Creer
         CreateVM()
      Case $Cloner
         ClonageHD()
      Case $Quitter
         Exit
   EndSwitch
Until $nMsg = $GUI_EVENT_CLOSE


Func CreateVM()
   ;création d'un tableur 1D contenant les types d'OS de VirtualBox.
   Global $OsType[62] = ["Other", "Windows31", "Windows95", "Windows98", "WindowsMe", _
         "WindowsNT4", "WindowsNT", "Windows2000", "Windows2003", "Windows2003_64", "Windows2008", "Windows2008_64", _
         "WindowsXP", "WindowsXP_64", "WindowsVista", "WindowsVista_64", "Windows7", "Windows7_64", _
         "Linux", "Linux22", "Linux24", "Linux24_64", "Linux26", "Linux26_64", "ArchLinux", "ArchLinux_64", "Debian", "Debian_64", "OpenSUSE", "OpenSUSE_64", _
         "Fedora", "Fedora_64", "Gentoo", "Gentoo_64", "Mandriva", "Mandriva_64", "RedHat", "RedHat_64", "Turbolinux", "Ubuntu", "Ubuntu_64", _
         "Xandros", "Xandros_64", "Solaris", "Solaris_64", "OpenSolaris", "OpenSolaris_64", _
         "FreeBSD", "FreeBSD_64", "OpenBSD", "OpenBSD_64", "NetBSD", "NetBSD_64", _
         "OS2Warp3", "OS2Warp4", "OS2Warp45", "OS2eCS", "OS2", _
         "DOS", "Netware", "L4", "QNX"]
   ;ID créer une Gui
   #Region ### START Koda GUI section ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\GuiCreateVM.kxf
   Global $GuiCreateVM = GUICreate("GuiCreateVM", 505, 213, 190, 121)
   Global $PathDir = GUICtrlCreateInput("PathDir", 96, 56, 385, 21)
   Global $VDI = GUICtrlCreateInput("VDI", 96, 96, 385, 21)
   Global $Go = GUICtrlCreateButton("Go", 328, 176, 75, 25)
   GUICtrlSetOnEvent($Go, "GoCreate")
   Global $Label1 = GUICtrlCreateLabel("Dossier :", 24, 56, 45, 17)
   Global $Label2 = GUICtrlCreateLabel("Image vdi", 24, 96, 54, 17)
   Global $MemoryRAM = GUICtrlCreateInput("MemoryRAM", 96, 136, 105, 21)
   Global $Memoire = GUICtrlCreateLabel("Memoire RAM :", 8, 144, 77, 17)
   Global $NameNewVM = GUICtrlCreateInput("NameVM", 96, 16, 121, 21)
   Global $Label3 = GUICtrlCreateLabel("Nom de la VM : ", 8, 16, 80, 17)
   Global $Label5 = GUICtrlCreateLabel("OS Type :", 272, 16, 52, 17)
   Global $ListOsType = GUICtrlCreateCombo("", 328, 16, 145, 25)
   Global $Fermer = GUICtrlCreateButton("Fermer", 416, 176, 75, 25)
   GUICtrlSetOnEvent($Fermer, "Fermer")
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###


   For $i In $OsType
      GUICtrlSetData($ListOsType, _ArrayToString($OsType, "|")) ;lecture du tableau
   Next

EndFunc   ;==>CreateVM

Func GoCreate()
   $OS = GUICtrlRead($ListOsType)
   ;note OStype est accessible via vboxmanage list Ostypes
   #cs
      ID:          WindowsXP
      Description: Windows XP

      ID:          Windows7
      Description: Windows 7
   #ce
   ;command de création Nom de la VM - createvm, modifyvm, storagectl, storageattach
   ProgressOn("Custom VirtualBox", "Création de " & GUICtrlRead($NameNewVM)) ;création d'une progressBar.
   ProgressSet("20")
   RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" createvm --name "' & GUICtrlRead($NameNewVM) & '" --ostype "' & $OS & '" --basefolder "' & GUICtrlRead($PathDir) & '" --register', $PathVirtualBox, @SW_HIDE) ;VM bien crée dans le dossier indiqué
   ProgressSet("40")
   RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" modifyvm "' & GUICtrlRead($NameNewVM) & '" --memory ' & GUICtrlRead($MemoryRAM), $PathVirtualBox, @SW_HIDE) ; memoire prise en compte
   ProgressSet("60")
   RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" storagectl "' & GUICtrlRead($NameNewVM) & '" --name "IDE Controller" --add ide --controller PIIX4', $PathVirtualBox, @SW_HIDE) ; création du Controlleur IDE
   ProgressSet("80")
   RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" storageattach "' & GUICtrlRead($NameNewVM) & '" --storagectl "IDE Controller"  --port 0 --device 0 --type hdd --medium "' & GUICtrlRead($VDI) & '"', $PathVirtualBox, @SW_HIDE) ;vdi attachée
   ProgressSet(100, "Fini")
   Sleep(500)
   ProgressOff()
   KillGui3() ; fermer la Gui.
EndFunc   ;==>GoCreate




Func BrowseSrc()
   Local $ListInfo = "InfoSourceVDI.txt"
   Local $message = "Selectionne la source de ton fichier VDI."
   Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers VirtualBox (*.vdi;*.vmdk;*.vbox)", 1)
   GUICtrlSetData($SourceFile, $var)
   IniWrite(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", GUICtrlRead($SourceFile))
   $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
   FileChangeDir(@ScriptDir)
   RunWait(@ComSpec & ' /c "' & $PathVirtualBox & 'VBoxManage.exe"' & " showhdinfo " & $IniSource & " > " & $ListInfo, "", @SW_HIDE)
   $file = FileOpen("InfoSourceVDI.txt", 0)
   While 1
      $Line = FileReadLine($file)
      If @error Then ExitLoop
      If StringLeft($Line, 5) = "UUID:" Then $String1 = StringTrimLeft($Line, 6)
      If StringLeft($Line, 11) = "Accessible:" Then $String2 = StringTrimLeft($Line, 22)
      If StringLeft($Line, 13) = "Logical size:" Then $String3 = StringTrimLeft($Line, 14)
   WEnd
   FileClose($file)
   GUICtrlSetData($UUID, $String1)
   If StringUpper($String2) = "yes" Then
      GUICtrlSetColor($Valid, 0x00ff00) ; green VM Ok
      GUICtrlSetData($Valid, $String2)
   Else
      GUICtrlSetColor($Valid, 0xff0000) ; Red VM Non accessible
      GUICtrlSetData($Valid, $String2)
   EndIf
   GUICtrlSetData($SizeHD, Mo_To_Go($String3) & " Go") ; lecture et conversion des Mo en Go
EndFunc   ;==>BrowseSrc

Func BrowseDst()
   Local $message = "Sélectionne la destination de ton fichier VDI."
   Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers (*.vdi)")
   GUICtrlSetData($DestinationFile, $var)
   IniWrite(@DesktopDir & "\CloneVDIinfo.ini", "parametres", "Destination", GUICtrlRead($DestinationFile))
   $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
EndFunc   ;==>BrowseDst

Func Mo_To_Go($mo, $decimal = 3)
   Return Round($mo / 1024, $decimal)
EndFunc   ;==>Mo_To_Go

Func ClonageHD()
   #Region ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf
   $ClonageHD = GUICreate("Clonage Disque Virtuel", 306, 135, 192, 124)
   $Group1 = GUICtrlCreateGroup("En Cours", 8, 8, 289, 73)
   $Progress1 = GUICtrlCreateProgress(16, 40, 265, 17)
   GUICtrlCreateGroup("", -99, -99, 1, 1)
   $Annuler = GUICtrlCreateButton("Annuler", 208, 96, 81, 25)
   GUICtrlSetOnEvent($Annuler, "Annuler")
   GUISetState(@SW_SHOW, $ClonageHD)
   #EndRegion ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf


   #Region ### Action de clonage
   $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
   $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
   $pid = Run('"' & $PathVirtualBox & 'VBoxManage.exe clonehd "' & $IniSource & '" "' & $IniDestination & '"', $PathVirtualBox, @SW_HIDE)
   $total = FileGetSize($IniSource) ; ici il faudra mettre la taille du fichier source qui se fera clôner
   AdlibRegister("Update_progress", 1000)
   #EndRegion ### Action de clonage


EndFunc   ;==>ClonageHD

Func Annuler()
   $Choix = MsgBox(2, "Annuler par l'utilisateur", "Annuler ?")
   Switch $Choix
      Case 3
         ProcessClose($pid)
         ProcessClose("vboxSVC.exe")
         KillGui2()
      Case 4
      Case 5
   EndSwitch
EndFunc   ;==>Annuler


Func KillGui2()
   GUIDelete($ClonageHD)
EndFunc   ;==>KillGui2

Func KillGui3()
   GUIDelete($GuiCreateVM)
EndFunc   ;==>KillGui3

Func Fermer() ;Bouton fermer Gui3 - CreateVM()
   GUIDelete($GuiCreateVM)
EndFunc   ;==>Fermer

Func Sortie()
   If @GUI_WinHandle = $GuiCloneVDI Then
      Exit
   Else
      GUIDelete(@GUI_WinHandle)
   EndIf
EndFunc   ;==>Sortie

#Region ### fonction pour la progressbar
Func Update_progress()
   $pourcent = Int(FileGetSize($IniDestination) / $total * 100) ; calcul de la taille Destination en fonction de la source
   ConsoleWrite($pourcent & @CRLF)
   GUICtrlSetData($Progress1, $pourcent)
   If Not ProcessExists($pid) Then
      GUICtrlSetData($Progress1, 100)
      MsgBox("0", "Terminer", "Clonage Terminé")
      AdlibUnRegister("Update_progress")
      KillGui2()
   EndIf
EndFunc   ;==>Update_progress
#EndRegion ### fonction pour la progressbar





______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Répondre en citant
Message [Terminer] CloneVDIManager 
[-] Modification mise en vert dans le code.
[+] Double ComboList pour le type d'OS
[+] Ajout func Actived() pour l'activation de la 2nd comboList
[+] Modification de la variable $OS pour récupérer la valeur de la 2nd combolist.

Code:

#include <Array.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#cs
    CloneVDI Manager v1.1 By Laddy
    Cheffe de Projet : Laddy

    Command Line VboxManager :http://www.virtualbox.org/manual/ch08.html
    http://www.virtualbox.org/manual/ch08.html#vboxmanage-showvminfo
    http://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi
    http://www.virtualbox.org/manual/ch08.html#id494539 (vboxmanage-createvm)
    http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm
    http://www.virtualbox.org/manual/ch08.html#id508609 (VBoxManage.exe storageattach)
    http://www.virtualbox.org/manual/ch08.html#vboxmanage-storagectl

    Merci à l'ensemble des membres et équipes de Autoscript.fr The Forum pour leurs patiences et explications.
#ce
Opt("GUIOnEventMode", 1)
Global $String1, $String2, $String3, $IniDestination, $IniSource, $ClonageHD, $Annuler, $Progess1, $Creer, $BrowseDestination, $BrowseSource, $Cloner, $GuiCreateVM
Global $NameNewVM, $PathDir, $MemoryRAM, $VDI, $OS, $OSarch, $ListOsType, $OsType
Local $Progress1, $pid, $pourcent, $total

Dim $id = "0", $cmd, $line, $temp, $type, $item1, $item2, $array, $OSarch, $OsType[1][3]
#Region ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf
$GuiCloneVDI = GUICreate("CloneVDIManager", 588, 356, 506, 332)
GUISetOnEvent($GUI_EVENT_CLOSE, "Sortie")
$Group1 = GUICtrlCreateGroup("Fichiers", 16, 16, 553, 113)
$Source = GUICtrlCreateLabel("Source :", 32, 48, 44, 17)
$Destination = GUICtrlCreateLabel("Destination : ", 32, 88, 66, 17)
$SourceFile = GUICtrlCreateInput("", 120, 48, 369, 21)
$DestinationFile = GUICtrlCreateInput("", 120, 88, 369, 21)
$BrowseSource = GUICtrlCreateButton("Parcourir...", 496, 48, 65, 25)
GUICtrlSetOnEvent($BrowseSource, "BrowseSrc")
$BrowseDestination = GUICtrlCreateButton("Parcourir...", 496, 88, 67, 25)
GUICtrlSetOnEvent($BrowseDestination, "BrowseDst")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Informations Source", 16, 136, 553, 105)
$Label4 = GUICtrlCreateLabel("UUID", 72, 160, 31, 17)
$UUID = GUICtrlCreateInput("", 128, 160, 361, 21)
$Label5 = GUICtrlCreateLabel("Taille du disque", 24, 200, 78, 17)
$SizeHD = GUICtrlCreateInput("", 128, 192, 161, 21)
$Label6 = GUICtrlCreateLabel("Accessibilite", 304, 200, 62, 17)
$Valid = GUICtrlCreateInput("", 376, 192, 177, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("A propos", 16, 256, 553, 49)
$Infos = GUICtrlCreateLabel("CloneVDIManager - Laddy -Cheffe de projet", 178, 271, 210, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Creer = GUICtrlCreateButton("Creer", 24, 312, 75, 25)
GUICtrlSetOnEvent($Creer, "CreateVM")
$Cloner = GUICtrlCreateButton("Cloner", 400, 312, 89, 25)
GUICtrlSetOnEvent($Cloner, "ClonageHD")
$Quitter = GUICtrlCreateButton("Quitter", 496, 312, 75, 25)
GUICtrlSetOnEvent($Quitter, "Sortie")
GUISetState(@SW_SHOW, $GuiCloneVDI)
#EndRegion ### GUI SECTION CLONEVDIMANAGER ### CloneVDIManager.kxf

;Variable
If @OSArch = "X64" Then $OSarch = "64"
;If StringRight($vbox_path, 1) = "\" Then $vbox_path = StringRegExpReplace($vbox_path, "\\$", "")

If RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Oracle\VirtualBox", "InstallDir") Then
    $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Oracle\VirtualBox", "InstallDir")
ElseIf RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\VirtualBox", "InstallDir") Then
    $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\VirtualBox", "InstallDir")
ElseIf RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\xVM VirtualBox", "InstallDir") Then
    $PathVirtualBox = RegRead("HKEY_LOCAL_MACHINE" & $OSarch & "\SOFTWARE\Sun\xVM VirtualBox", "InstallDir")
Else
    MsgBox(16, "VirtualBox", "Erreur d'installation ou le logiciel n'est pas installé sur ce poste.")
    Exit
EndIf



Do
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $BrowseSource
            BrowseSrc()
        Case $BrowseDestination
            BrowseDst()
        Case $Creer
            CreateVM()
        Case $Cloner
            ClonageHD()
        Case $Quitter
            Exit
    EndSwitch
Until $nMsg = $GUI_EVENT_CLOSE


Func CreateVM()
    Dim $id = "0", $cmd, $line, $temp, $type, $item1, $item2, $array, $OSarch, $OsType[1][3]
    ;création d'un tableur 1D contenant les types d'OS de VirtualBox.
    #CS
        Global $OsType[62] = ["Other", "Windows31", "Windows95", "Windows98", "WindowsMe", _
        "WindowsNT4", "WindowsNT", "Windows2000", "Windows2003", "Windows2003_64", "Windows2008", "Windows2008_64", _
        "WindowsXP", "WindowsXP_64", "WindowsVista", "WindowsVista_64", "Windows7", "Windows7_64", _
        "Linux", "Linux22", "Linux24", "Linux24_64", "Linux26", "Linux26_64", "ArchLinux", "ArchLinux_64", "Debian", "Debian_64", "OpenSUSE", "OpenSUSE_64", _
        "Fedora", "Fedora_64", "Gentoo", "Gentoo_64", "Mandriva", "Mandriva_64", "RedHat", "RedHat_64", "Turbolinux", "Ubuntu", "Ubuntu_64", _
        "Xandros", "Xandros_64", "Solaris", "Solaris_64", "OpenSolaris", "OpenSolaris_64", _
        "FreeBSD", "FreeBSD_64", "OpenBSD", "OpenBSD_64", "NetBSD", "NetBSD_64", _
        "OS2Warp3", "OS2Warp4", "OS2Warp45", "OS2eCS", "OS2", _
        "DOS", "Netware", "L4", "QNX"]
    #CE

;Code FernandG.
[color=#408000]
    $cmd = Run('"' & $PathVirtualBox & 'VBoxManage.exe" list ostypes', $PathVirtualBox, @SW_HIDE, $STDOUT_CHILD)
    While 1
        $line = StdoutRead($cmd)
        If @error Then ExitLoop
        If $line <> "" Then $temp &= StringStripWS($line, 4)
    WEnd

    $array = StringSplit($temp, @CRLF)
    For $i = 1 To $array[0]
        If StringRegExp($array[$i], "^ID:.*", 0) Then
            $OsType[$id][0] = StringRegExpReplace($array[$i], "^ID:\s+", "")
            Select
                Case StringRegExp($OsType[$id][0], "(?i)Windows", 0) = 1
                    $OsType[$id][2] = "Microsoft Windows"
                Case StringRegExp($OsType[$id][0], "(?i)Linux", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Debian", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)openSUSE", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Fedora", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Gentoo", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Mandriva", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)RedHat", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Ubuntu", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Xandros", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Oracle", 0) = 1
                    $OsType[$id][2] = "Linux"
                Case StringRegExp($OsType[$id][0], "(?i)Solaris", 0) = 1
                    $OsType[$id][2] = "Solaris"
                Case StringRegExp($OsType[$id][0], "(?i)BSD", 0) = 1
                    $OsType[$id][2] = "BSD"
                Case StringRegExp($OsType[$id][0], "(?i)OS2", 0) = 1
                    $OsType[$id][2] = "IBM OS/2"
                Case StringRegExp($OsType[$id][0], "(?i)MacOS", 0) = 1
                    $OsType[$id][2] = "Mac OS X"
                Case Else
                    $OsType[$id][2] = "Other"
            EndSelect
            $id += 1
            ReDim $OsType[$id + 1][3]
        EndIf
        If StringRegExp($array[$i], "^Description:.*", 0) Then $OsType[$id - 1][1] = StringRegExpReplace($array[$i], "^Description:\s+", "")
    Next
    If $OsType[UBound($OsType) - 1][0] = "" Then ReDim $OsType[$id][3][/color]


    ;ID créer une Gui
    #Region ### START Koda GUI section ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\GuiCreateVM.kxf
    Global $GuiCreateVM = GUICreate("GuiCreateVM", 506, 214, 190, 121)
    Global $PathDir = GUICtrlCreateInput("PathDir", 96, 80, 385, 21)
    Global $VDI = GUICtrlCreateInput("VDI", 96, 120, 385, 21)
    Global $Go = GUICtrlCreateButton("Go", 328, 176, 75, 25)
    GUICtrlSetOnEvent($Go, "GoCreate")
    Global $Label1 = GUICtrlCreateLabel("Dossier :", 24, 80, 45, 17)
    Global $Label2 = GUICtrlCreateLabel("Image vdi", 24, 120, 54, 17)
    Global $MemoryRAM = GUICtrlCreateInput("MemoryRAM", 96, 160, 105, 21)
    Global $Memoire = GUICtrlCreateLabel("Memoire RAM :", 8, 168, 77, 17)
    Global $NameNewVM = GUICtrlCreateInput("NameVM", 96, 16, 121, 21)
    Global $Label3 = GUICtrlCreateLabel("Nom de la VM :", 8, 16, 80, 17)
    Global $Label5 = GUICtrlCreateLabel("OS Type :", 272, 16, 52, 17)
    Global $ListOsType = GUICtrlCreateCombo("", 328, 16, 145, 25)
    $type = _ArrayUnique($OsType, 3)
    For $i = 1 To $type[0]
        $item1 &= $type[$i] & "|"
    Next
    GUICtrlSetData(-1, $item1)
    GUICtrlSetOnEvent($ListOsType, "Actived")
    Global $product = GUICtrlCreateCombo("", 328, 48, 145, 25)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Global $Fermer = GUICtrlCreateButton("Fermer", 416, 176, 75, 25)
    GUICtrlSetOnEvent($Fermer, "Fermer")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section #

EndFunc   ;==>CreateVM

[color=#408000]Func Actived() ; activation 2nd combo
    $item2 = "|"
    GUICtrlSetState($product, $GUI_ENABLE)
    For $i = 1 To UBound($OsType) - 1
        If $OsType[$i][2] = GUICtrlRead($ListOsType) Then $item2 &= $OsType[$i][1] & "|"
    Next
    GUICtrlSetData($product, $item2)
EndFunc ;==>Actived[/color]

Func GoCreate()
    [color=#408000]$OS = $ostype[_ArraySearch($ostype, GUICtrlRead($product))][0][/color]
    ;note OStype est accessible via vboxmanage list Ostypes
    #cs
        ID:          WindowsXP
        Description: Windows XP

        ID:          Windows7
        Description: Windows 7
    #ce
    ;command de création Nom de la VM - createvm, modifyvm, storagectl, storageattach
    ConsoleWrite($OS)
    ProgressOn("Custom VirtualBox", "Création de " & GUICtrlRead($NameNewVM)) ;création d'une progressBar.
    ProgressSet("20")
    RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" createvm --name "' & GUICtrlRead($NameNewVM) & '" --ostype "' & $OS & '" --basefolder "' & GUICtrlRead($PathDir) & '" --register', $PathVirtualBox, @SW_HIDE) ;VM bien crée dans le dossier indiqué
    ProgressSet("40")
    RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" modifyvm "' & GUICtrlRead($NameNewVM) & '" --memory ' & GUICtrlRead($MemoryRAM), $PathVirtualBox, @SW_HIDE) ; memoire prise en compte
    ProgressSet("60")
    RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" storagectl "' & GUICtrlRead($NameNewVM) & '" --name "IDE Controller" --add ide --controller PIIX4', $PathVirtualBox, @SW_HIDE) ; création du Controlleur IDE
    ProgressSet("80")
    RunWait('"' & $PathVirtualBox & 'VBoxManage.exe" storageattach "' & GUICtrlRead($NameNewVM) & '" --storagectl "IDE Controller"  --port 0 --device 0 --type hdd --medium "' & GUICtrlRead($VDI) & '"', $PathVirtualBox, @SW_HIDE) ;vdi attachée
    ProgressSet(100, "Fini")
    Sleep(500)
    ProgressOff()
    KillGui3() ; fermer la Gui.
EndFunc   ;==>GoCreate




Func BrowseSrc()
    Local $ListInfo = "InfoSourceVDI.txt"
    Local $message = "Selectionne la source de ton fichier VDI."
    Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers VirtualBox (*.vdi;*.vmdk;*.vbox)", 1)
    GUICtrlSetData($SourceFile, $var)
    IniWrite(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", GUICtrlRead($SourceFile))
    $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
    FileChangeDir(@ScriptDir)
    RunWait(@ComSpec & ' /c "' & $PathVirtualBox & 'VBoxManage.exe"' & " showhdinfo " & $IniSource & " > " & $ListInfo, "", @SW_HIDE)
    $file = FileOpen("InfoSourceVDI.txt", 0)
    While 1
        $line = FileReadLine($file)
        If @error Then ExitLoop
        If StringLeft($line, 5) = "UUID:" Then $String1 = StringTrimLeft($line, 6)
        If StringLeft($line, 11) = "Accessible:" Then $String2 = StringTrimLeft($line, 22)
        If StringLeft($line, 13) = "Logical size:" Then $String3 = StringTrimLeft($line, 14)
    WEnd
    FileClose($file)
    GUICtrlSetData($UUID, $String1)
    If StringUpper($String2) = "yes" Then
        GUICtrlSetColor($Valid, 0x00ff00) ; green VM Ok
        GUICtrlSetData($Valid, $String2)
    Else
        GUICtrlSetColor($Valid, 0xff0000) ; Red VM Non accessible
        GUICtrlSetData($Valid, $String2)
    EndIf
    GUICtrlSetData($SizeHD, Mo_To_Go($String3) & " Go") ; lecture et conversion des Mo en Go
EndFunc   ;==>BrowseSrc

Func BrowseDst()
    Local $message = "Sélectionne la destination de ton fichier VDI."
    Local $var = FileOpenDialog($message, @DesktopDir & "\", "Fichiers (*.vdi;*.vbox)")
    GUICtrlSetData($DestinationFile, $var)
    IniWrite(@DesktopDir & "\CloneVDIinfo.ini", "parametres", "Destination", GUICtrlRead($DestinationFile))
    $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
EndFunc   ;==>BrowseDst

Func Mo_To_Go($mo, $decimal = 3)
    Return Round($mo / 1024, $decimal)
EndFunc   ;==>Mo_To_Go

Func ClonageHD()
    #Region ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf
    $ClonageHD = GUICreate("Clonage Disque Virtuel", 306, 135, 192, 124)
    $Group1 = GUICtrlCreateGroup("En Cours", 8, 8, 289, 73)
    $Progress1 = GUICtrlCreateProgress(16, 40, 265, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Annuler = GUICtrlCreateButton("Annuler", 208, 96, 81, 25)
    GUICtrlSetOnEvent($Annuler, "Annuler")
    GUISetState(@SW_SHOW, $ClonageHD)
    #EndRegion ### GUI Clonage ### Form=D:\Téléchargements\koda_1.7.3.0\Forms\ClonageHardDisk.kxf


    #Region ### Action de clonage
    $IniSource = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Source", "NotFound")
    $IniDestination = IniRead(@ScriptDir & "\CloneVDIinfo.ini", "parametres", "Destination", "NotFound")
    $pid = Run('"' & $PathVirtualBox & 'VBoxManage.exe clonehd "' & $IniSource & '" "' & $IniDestination & '"', $PathVirtualBox, @SW_HIDE)
    $total = FileGetSize($IniSource) ; ici il faudra mettre la taille du fichier source qui se fera clôner
    AdlibRegister("Update_progress", 1000)
    #EndRegion ### Action de clonage


EndFunc   ;==>ClonageHD

Func Annuler()
    $Choix = MsgBox(2, "Annuler par l'utilisateur", "Annuler ?")
    Switch $Choix
        Case 3
            ProcessClose($pid)
            ProcessClose("vboxSVC.exe")
            KillGui2()
        Case 4
        Case 5
    EndSwitch
EndFunc   ;==>Annuler


Func KillGui2()
    GUIDelete($ClonageHD)
EndFunc   ;==>KillGui2

Func KillGui3()
    GUIDelete($GuiCreateVM)
EndFunc   ;==>KillGui3

Func Fermer() ;Bouton fermer Gui3 - CreateVM()
    GUIDelete($GuiCreateVM)
EndFunc   ;==>Fermer

Func Sortie()
    If @GUI_WinHandle = $GuiCloneVDI Then
        Exit
    Else
        GUIDelete(@GUI_WinHandle)
    EndIf
EndFunc   ;==>Sortie

#Region ### fonction pour la progressbar
Func Update_progress()
    $pourcent = Int(FileGetSize($IniDestination) / $total * 100) ; calcul de la taille Destination en fonction de la source
    ConsoleWrite($pourcent & @CRLF)
    GUICtrlSetData($Progress1, $pourcent)
    If Not ProcessExists($pid) Then
        GUICtrlSetData($Progress1, 100)
        MsgBox("0", "Terminer", "Clonage Terminé")
        AdlibUnRegister("Update_progress")
        KillGui2()
    EndIf
EndFunc   ;==>Update_progress
#EndRegion ### fonction pour la progressbar






______________________________________________________
Faites paraitre votre batch sur BatchClipboard
Visiter le site web du posteur
Message [Terminer] CloneVDIManager 


Montrer les messages depuis:
Répondre au sujet Page 2 sur 2
Aller à la page: <  1, 2
  



Index | créer un forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Copyright 2008 - 2016 // Batch