MSFN Forum: Batch script for imagex error - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch script for imagex error need help with batch script Rate Topic: -----

#1 User is offline   yweiss 

  • Group: Members
  • Posts: 5
  • Joined: 08-November 11
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 08 November 2011 - 04:04 PM

Hello,
I'm using this great batch script to capture and apply my image
@echo off 
cd /d %~dp0 
if not exist "imagex.exe" goto _notexist 
goto _main 
:_notexist 
echo. 
echo IMAGEX.EXE executable not found. Please ensure that IMAGEX_APPLY.CMD  
echo is in the same folder as IMAGEX.EXE before executing this script. 
echo This script will now exit. 
echo. 
pause 
exit 
 
:_main 
echo. 
echo. 
echo. 
echo     [I M A G E X     A P P L Y     M A I N     M E N U] 
echo. 
echo     1) Specify or change source path (the path to you .wim image file) 
echo        Source: [%_asource%] 
echo. 
echo     2) Specify or change target path, where your image will be restored 
echo        Target: [%_atarget%] 
echo. 
echo     3) Specify or change index you want to restore (a number, such as 2) 
echo        Index: [%_index%] 
echo. 
if "%_asource%" == "" goto _menu1 
if "%_atarget%" == "" goto _menu1 
if "%_index%" == "" goto _menu1 
echo     4) Apply your image now where ready 
echo        From [%_asource%] To [%_atarget%] 
echo. 
 
:_menu1 
echo     Q) Quit.    R) Reset all variables. 
echo. 
 
:_mainch 
set _ok= 
set /p _ok=Enter your choice:  
if "%_ok%" == "1" goto _getsrc 
if "%_ok%" == "2" goto _gettarget 
if "%_ok%" == "3" goto _getindex 
if "%_ok%" == "4" goto _apply 
if /I "%_ok%" == "q" goto _end 
if /I "%_ok%" == "r" goto _reset 
goto _mainch 
 
:_getsrc 
set _ok= 
echo. 
echo Specify location of source image to restore with full path. 
set /p _ok=Enter Source path:  
for %%A in (%_ok%) do set _ext=%%~xA 
if not exist %_ok% ( 
        echo. 
        echo --------------------------------------------------------- 
        echo Path does not exist. Please input a valid location again. 
        echo --------------------------------------------------------- 
        goto _getsrc 
) else ( 
        if /I "%_ext%"==".wim" ( 
        set _asource=%_ok% 
        setx _asource %_ok% 
        goto _main 
) else ( 
        echo. 
        echo --------------------------------------------------------------- 
        echo Error: The path "%_ok%" does not seem to be a valid .wim image file. 
        echo --------------------------------------------------------------- 
        goto _getsrc 
) 
) 
 
:_gettarget 
set _ok= 
echo. 
echo Specify target to install source image with full path. 
set /p _ok=Enter Target path:  
if exist "%_ok%" ( 
        set _atarget=%_ok% 
        setx _atarget %_ok% 
) else ( 
        echo. 
        echo --------------------------------------------------------------- 
        echo Error: The path "%_ok%" is not a correct location. 
        echo --------------------------------------------------------------- 
        goto _gettarget 
) 
 
goto _main 
 
:_getindex 
set _ok= 
echo. 
echo Specify image index with a number 
set /p _ok=Enter Index number:  
set _index=%_ok% 
setx _index %_ok% 
goto _main 
 
:_apply 
echo. 
echo. 
@echo on 
imagex.exe /apply "%_asource%" %_index% "%_atarget%" 
@echo off 
echo. 
pause 
goto _end 
 
:_reset 
set _asource= 
set _index= 
set _atarget= 
goto _main 
 
:_end


but there is a problem that when i want to choose my .wim file it keep say to me that : Error: The path "%_ok%" does not seem to be a valid .wim image file.
even when i put the correct full path for the wim file
someone can help me with it?
and also i want that after the apply prcess complete the script will run the next command
d:\windows\system32\bcdboot d:\windows
when d: is the drive that the wim file was install to (the hard drive that windows will be in it) so i want that the script will ask for the drive letter or will use one of the variabels from it

10x

This post has been edited by yweiss: 08 November 2011 - 04:10 PM



#2 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,726
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 09 November 2011 - 09:47 AM

I hazard a guess that _ext=%%~xA
Which is set during the For above your three outcomes in the IF statement that follows. If that is the case, then it the variable would exist, and not equal .wim, which only allows for the error to appear. I'm not too good at batch so I'll let others check it out.

#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 09 November 2011 - 02:27 PM

I've made a couple of minor changes to what you posted, give it a try and post back your findings:
@echo off
pushd %~dp0
if not exist "imagex.exe" goto _notexist

:_main
echo=
echo=
echo=
echo=    [I M A G E X     A P P L Y     M A I N     M E N U]
echo=
echo=    1) Specify or change source path (the path to your .wim image file)
echo=       Source: [%_asource%]
echo=
echo=    2) Specify or change target path, where your image will be restored
echo=       Target: [%_atarget%]
echo=
echo=    3) Specify or change index you want to restore (a number, such as 2)
echo=       Index: [%_index%]
echo=
if "%_asource%"=="" goto _menu1
if "%_atarget%"=="" goto _menu1
if "%_index%"=="" goto _menu1
echo=    4) Apply your image now where ready
echo=       From [%_asource%] To [%_atarget%]
echo=

:_menu1
echo=    Q) Quit.    R) Reset all variables.
echo=

:_mainch
set "_ok="
set /p "_ok=Enter your choice: "
if "%_ok%"=="1" goto _getsrc
if "%_ok%"=="2" goto _gettarget
if "%_ok%"=="3" goto _getindex
if "%_ok%"=="4" goto _apply
if /I "%_ok%"=="q" (popd & goto :eof)
if /I "%_ok%"=="r" goto _reset
goto _mainch

:_getsrc
set _ok=
echo=
echo=Specify location of source image to restore with full path.
set /p "_ok=Enter Source path: "
if not exist "%_ok%" (
        echo.
        echo ---------------------------------------------------------
        echo Path does not exist. Please input a valid location again.
        echo ---------------------------------------------------------
        goto _getsrc
)
for %%A in ("%_ok%") do (
	if /I "%%~xA"==".wim" (
		set "_asource=%_ok%"
		(setx _asource %_ok%)
		goto _main
	) else (
		echo=
		echo=---------------------------------------------------------------
		echo=Error: The path "%_ok%" does not seem to be a valid .wim image file.
		echo=---------------------------------------------------------------
		goto _getsrc
	)
)

:_gettarget
set "_ok="
echo=
echo=Specify target to install source image with full path.
set /p "_ok=Enter Target path: "
if not exist "_ok" (
	echo=
	echo=---------------------------------------------------------------
	echo=Error: The path "%_ok%" is not a correct location.
	echo=---------------------------------------------------------------
	goto _gettarget
)
set "_atarget=%_ok%"
(setx _atarget %_ok%)
goto _main

:_getindex
set "_ok="
echo=
echo=Specify image index with a number
set /p "_ok=Enter Index number: "
set "_index=%_ok%"
(setx _index %_ok%)
goto _main
 
:_apply
echo=
echo=
@echo on
imagex.exe /apply "%_asource%" %_index% "%_atarget%"
@echo off
echo=
pause
popd
goto :eof
 
:_reset
set "_asource="
set "_index="
set "_atarget="
goto _main

:_notexist
echo=
echo=IMAGEX.EXE executable not found. Please ensure that %~nx0
echo=is in the same folder as IMAGEX.EXE before executing this script.
echo=This script will now exit.
echo=
pause
popd

This post has been edited by Yzöwl: 10 November 2011 - 01:17 PM
Reason for edit: missing closing parentheses added


#4 User is online   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,356
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 09 November 2011 - 03:18 PM

Here try this HTA if you want a GUI to work with.
Attached File  ImageXHta.png (32.95K)
Number of downloads: 14
<!--
 Created By Gunsmokingman Aka Jake1Eye
1:15 PM November-09-11
-->
<TITLE>ImageX Gui</TITLE>
<HTA:APPLICATION ID="ImageX Gui"
  APPLICATIONNAME="ImageXGui"
  Border="Thin"
  BORDERSTYLE ="Complex"
  Caption="Yes"
  INNERBORDER ="No"
  MaximizeButton="No" 
  MinimizeButton="No" 
  Scroll="No" 
  SCROLLFLAT ="No"        
  SingleInstance="Yes"
  SysMenu="No"           
  WindowState="Normal"/>
<STYLE Type='text/css'>
  Body
   {
    Font-Size:9.25pt;
    Font-Weight:Bold;
    Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
    Color:Black;
    BackGround-Color:Transparent;
    Filter:progid:DXImageTransform.Microsoft.Gradient
    (StartColorStr='#ece6e0',EndColorStr='#c0bab4');
    Margin-Top:21;
    Margin-Bottom:1;
    Margin-Left:4;
    Margin-Right:4;
    Padding-Top:1;
    Padding-Bottom:1;
    Padding-Left:4;
    Padding-Right:4;
    Text-Align:Center;
    Vertical-Align:Top;
    Border-Top:0px Transparent;
    Border-Bottom:0px Transparent;
    Border-Left:0px Transparent;
    Border-Right:0px Transparent;
   }
  BUTTON
   {
    Cursor:Hand;
    Height:19;
    Width:69;
    Font-Size:8.25pt;
    Font-Weight:Bold;
    Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
    Color:#001141;
    Text-Align:Center;
    Vertical-Align:Middle;
    Filter:progid:DXImageTransform.Microsoft.Gradient
    (StartColorStr='AliceBlue',endColorStr='LightSlateGray');
    Border-Top:0px Transparent;
    Border-Bottom:0px Transparent;
    Border-Left:0px Transparent;
    Border-Right:0px Transparent;
    Padding-Top:0;
    Padding-Bottom:2;
    Padding-Left:0;
    Padding-Right:0;
    Margin-Top:1;
    Margin-Bottom:1;
    Margin-Left:1;
    Margin-Right:1;
    BackGround-Color:Transparent;
   }
  TABLE
   {
    Font-Size:8.25pt;
    Font-Weight:Bold;
    Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
    Color:Black;
    Margin-Top:-1;
   }
</STYLE>
<script Language='VBScript'>
Const MY_COMPUTER = &H11&
'-> Resize And Move Window
 Dim Wth :Wth = int(500)
 Dim Hht :Hht = int(275)
   window.ResizeTo Wth, Hht
   MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))
'-> Objects For Run Time
 Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim Shl :Set Shl = CreateObject("Shell.Application") 
'-> Varible To Check imagex.exe = True
  Dim ChkImageX
'-> Window On Load Function
   Function Window_onLoad()
    If Fso.FileExists("imagex.exe") Then ChkImageX = True 
   End Function
'-> Function To Brows For Folder And Return The Folder Path
   Function FolderPath(MyTxt,Arg)
    Dim Brows
    Set Brows = Shl.BrowseForFolder(0,MyTxt, 0, MY_COMPUTER)
'-> Press The Cancel Button
    If Brows Is Nothing Then
     MsgBox  "User Cancel Process",4128,"User Cancel"
     Exit Function
'-> Press The Ok Button Without Selecting A Folder, Or Root Drive Selected
    ElseIf InStr(1,Brows.Items.Item,"Computer",1) Or _
    Len(Brows.Self.Path) = 3 Then
'-> Ask To ReDo Folder Selection
    If MsgBox("Error Not A Valid Folder Location : " & _
      Brows.Items.Item & vbCrLf & _
     "Would You Like To Continue The Script?",4132, _
     "Continue Or Quit") = 6 Then
     call FolderPath(MyTxt,Arg)
     Else
     Exit Function
     End If 
    Else
'-> Process Folder Selection
     Select Case Arg
      Case 1
       TxBox1.value = Brows.Self.Path
      Case 2
       TxBox2.value = Brows.Self.Path
     End Select
    End If 
   End Function
'-> Function Submit Information Button
   Function CheckTxBox()
   Dim Chk1, Chk2, Chk3
'-> Check The Textbox For True Or False Values
     If TxBox1.value <> "" And Fso.FolderExists(TxBox1.value) Then
      Chk1 = True
     Else
      Chk1 = False
     End If 
     If TxBox2.value <> ""  And Fso.FolderExists(TxBox2.value) Then
      Chk2 = True
     Else
      Chk2 = False
     End If 
     If TxBox3.value <> "" And IsNumeric(TxBox3.value) Then
      Chk3 = True
     Else
      Chk3 = False
     End If 
'-> Check For Possible Combination True And False
     If Chk1 = True And Chk2 = True And Chk3 = True Then
       If ChkImageX = True Then
        alert("Processing ImageX Information"& vbcrlf & _
        TxBox1.value & vbcrlf & TxBox2.value & vbcrlf & _
        TxBox3.value)
        CreateObject("Wscript.Shell").Run(_
        "imagex.exe /apply " & TxBox1.value & " " & _
        TxBox3.value & " " & TxBox2.value),1,true
       Else
        alert("Error ImageX Missing From Current Directory"& vbcrlf & _
        "Can Not Process ImageX Information" & vbcrlf & _
        TxBox1.value & vbcrlf & TxBox3.value & vbcrlf & _
        TxBox2.value)
       End If 
     ElseIf Chk1 = False And Chk2 = True And Chk3 = True Then
      alert("Error Textbox 1, No Values" & vbcrlf & _
            "TextBox 1 = " & TxBox1.value & vbcrlf & _
            "TextBox 3 = " & TxBox3.value & vbcrlf & _
            "TextBox 2 = " & TxBox2.value)
     ElseIf Chk1 = False And Chk2 = False And Chk3 = True Then
      alert("Error Textbox 1, Textbox 2 No Values" & vbcrlf & _
            "TextBox 1 = " & TxBox1.value & vbcrlf & _
            "TextBox 3 = " & TxBox3.value & vbcrlf & _
            "TextBox 2 = " & TxBox2.value)
     ElseIf Chk1 = True And Chk2 = True And Chk3 = False Then
      alert("Error Textbox 3 Empty Or Not A Number" & vbcrlf & _
            "TextBox 1 = " & TxBox1.value & vbcrlf & _
            "TextBox 3 = " & TxBox3.value & vbcrlf & _
            "TextBox 2 = " & TxBox2.value)
    ElseIf Chk1 = True And Chk2 = False And Chk3 = False Then
      alert("Error Textbox 2 No Values, Textbox 3 No Number Or Value" & vbcrlf & _
            "TextBox 1 = " & TxBox1.value & vbcrlf & _
            "TextBox 3 = " & TxBox3.value & vbcrlf & _
            "TextBox 2 = " & TxBox2.value)
    ElseIf Chk1 = False And Chk2 = False And Chk3 = False Then
      alert("Error All 3 Textboxes Have No Values" & vbcrlf & _
            "TextBox 1 = " & TxBox1.value & vbcrlf & _
            "TextBox 3 = " & TxBox3.value & vbcrlf & _
            "TextBox 2 = " & TxBox2.value)
     End If
   End Function
</Script>
<BODY>
<!-- Container For Wim Path, Target Path, Index Start -->
<TABLE Style='Margin-Top:1;'><TD>
<!-- Textbox 1 Area Start -->
 <TABLE><TD Width='337' ID=''>
  Specify or change source path(the path to you .wim image file).
  Use the Brows Button to select the folder 
  <BUTTON ID='BtnBrows1' 
   OnClick= 'call FolderPath("Select The Source Wim Folder",1)'>
   Brows</BUTTON></TD></TABLE>
 <TABLE><TD><Input Type='text' Size='51' Name='TxBox1'></TD></TABLE>
<!-- Textbox 1 Area End -->
<!-- Textbox 2 Area Start -->
 <TABLE><TD Width='337' ID=''>
   Specify or change target path, where the image will be restored.
   Use the Brows Button to select the folder. 
  <BUTTON ID='BtnBrows2' 
   OnClick='call FolderPath("Select The Restore Image Folder",2)'>
   Brows</BUTTON></TD></TABLE>
 <TABLE><TD><Input Type='text' Size='51' Name='TxBox2'></TD></TABLE>
<!-- Textbox 2 Area End -->
<!-- Textbox 3 Area Start -->
  <TABLE><TD Width='289'>Type In The Index Number Of .Wim Image.<BR>Example 2</TD>
  <TD><Input Type='text' Size='2' Name='TxBox3'></TD></TABLE> 
<!-- Textbox 3 Area End -->
</TD></TABLE>
<!-- Container For Wim Path, Target Path, Index End -->
<!-- Button Container -->
 <TABLE Style='Margin-Top:3;'><TD>
  <BUTTON ID='bSubmit' OnClick='CheckTxBox()'>Subnit</BUTTON>
  <BUTTON ID='bClose' OnClick='window.Close()'>Close</BUTTON>
 </TD></TABLE>
</BODY>

Attached File(s)



#5 User is offline   yweiss 

  • Group: Members
  • Posts: 5
  • Joined: 08-November 11
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 10 November 2011 - 01:08 AM

yozel
the new script you did is not working...
when i try to choose my .wim file the script just close
and when i choose the target folder its keep telling me that the path is invaild (even when i choose exit folder)
can you plz help me??
and if you can help me with the command
d:\windows\system32 bcdboot d:\windows - i want that the script will do this command but before he will ask me where i apllyied the wim file and then it will run from this partition

10x

#6 User is offline   mchipser 

  • Junior
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 19-February 08

Posted 10 November 2011 - 09:02 AM

Try this..

Attachment has source and compiled versions.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=imagexgui.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;ImagexGUI

$PipeXML = "c:\imagexinfo.xml"

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

$ImageX_GUI = GUICreate("ImageX_GUI", 480, 165, 192, 124)
$Label1 = GUICtrlCreateLabel("Specify the WIM you would like to deploy.", 16, 16, 202, 17)
$Button1 = GUICtrlCreateButton("...",215,10,23,23)
$Button2 = GUICtrlCreateButton("Deploy",215,125,50,23)
$Label2 = GUICtrlCreateLabel("", 16, 40, 268, 17)
$Label3 = GUICtrlCreateLabel("Specify the Drive you would like to deploy to.", 16, 64, 216, 17)
$Label5 = GUICtrlCreateLabel("Specify the index of the WIM you would like to deploy.", 16, 88, 260, 17)
$Combo1 = GUICtrlCreateCombo("", 232, 56, 49, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 280, 80, 49, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)

$Drives = DriveGetDrive ( "Fixed" )
for $i = 1 to ubound($drives)-1
GuiCtrlSetData($combo1,$drives[$i])
next

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1
			$source = FileOpenDialog("What wim would you like to open?","C:\","WIM(*.WIM)")

			If FileExists ($PipeXML) Then FileDelete ($PipeXML)
			runwait(@comspec & ' /c "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /info ' & $Source & "> " & $PipeXML, "" ,@SW_HIDE)
			sleep(2000)
			$XMLdata = fileread ($PipeXML)
			$CatalogArray = StringRegExp ($XMLdata , '(?:IMAGE INDEX=")(\d)' , 3)

			for $i = 0 to ubound($CatalogArray)-1
			GuiCtrlSetData($combo2,$CatalogArray[$i])
			Next
			if FileExists($PipeXML) then FileDelete($PipeXML)
			GUICtrlSetData($Label2,$source)

		Case $Button2
			$drive = GUICtrlRead($combo1)
			$index = GUICtrlRead($combo2)
			if $drive = "" or $index = "" Then
				MsgBox(0,"","You have not made all required selections")
				ContinueLoop
			EndIf
			runwait(@comspec & ' /c "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /apply ' & $source & " " & $index & " " & $drive)
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd

Attached File(s)


This post has been edited by mchipser: 10 November 2011 - 09:03 AM


#7 User is offline   yweiss 

  • Group: Members
  • Posts: 5
  • Joined: 08-November 11
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 10 November 2011 - 09:16 AM

10x i will check it
but i i think there is problem
C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /apply ' & $source & " " & $index & " " & $drive
i run the script from winpe dvd disk and the imagex is not in this path, it in x:\windows\system32\imagex.exe
so how can i change it?

and i prefare it in batch script
and what about the last command: d:\windows\system32\bcdboot d:\windows
?

This post has been edited by yweiss: 10 November 2011 - 09:19 AM


#8 User is offline   mchipser 

  • Junior
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 19-February 08

Posted 10 November 2011 - 09:41 AM

try this..

Beggars cant be choosers.. If you want it in a batch file fix the one you posted.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=imagexgui.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;ImagexGUI

$PipeXML = "c:\imagexinfo.xml"

if not FileExists("imagex.exe") then
	MsgBox(0,"Error!","Imagex is not in the same directory as the script. Please run this from the same directory")
	Exit
EndIf

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

$ImageX_GUI = GUICreate("ImageX_GUI", 480, 165, 192, 124)
$Label1 = GUICtrlCreateLabel("Specify the WIM you would like to deploy.", 16, 16, 202, 17)
$Button1 = GUICtrlCreateButton("...",215,10,23,23)
$Button2 = GUICtrlCreateButton("Deploy",215,125,50,23)
$Label2 = GUICtrlCreateLabel("", 16, 40, 268, 17)
$Label3 = GUICtrlCreateLabel("Specify the Drive you would like to deploy to.", 16, 64, 216, 17)
$Label5 = GUICtrlCreateLabel("Specify the index of the WIM you would like to deploy.", 16, 88, 260, 17)
$Combo1 = GUICtrlCreateCombo("", 232, 56, 49, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 280, 80, 49, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)

$Drives = DriveGetDrive ( "Fixed" )
for $i = 1 to ubound($drives)-1
GuiCtrlSetData($combo1,$drives[$i])
next

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1
			$source = FileOpenDialog("What wim would you like to open?","C:\","WIM(*.WIM)")

			If FileExists ($PipeXML) Then FileDelete ($PipeXML)
			runwait(@comspec & ' /c "imagex.exe" /info ' & $Source & "> " & $PipeXML, "" ,@SW_HIDE)
			sleep(2000)
			$XMLdata = fileread ($PipeXML)
			$CatalogArray = StringRegExp ($XMLdata , '(?:IMAGE INDEX=")(\d)' , 3)

			for $i = 0 to ubound($CatalogArray)-1
			GuiCtrlSetData($combo2,$CatalogArray[$i])
			Next
			if FileExists($PipeXML) then FileDelete($PipeXML)
			GUICtrlSetData($Label2,$source)

		Case $Button2
			$drive = GUICtrlRead($combo1)
			$index = GUICtrlRead($combo2)
			if $drive = "" or $index = "" Then
				MsgBox(0,"","You have not made all required selections")
				ContinueLoop
			EndIf
			runwait(@comspec & ' /c "imagex.exe" /apply ' & $source & " " & $index & " " & $drive)
			runwait(@comspec & ' /c ' & $drive & "\windows\system32\bcdboot " & $drive & "\windows")
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd

Attached File(s)



#9 User is offline   yweiss 

  • Group: Members
  • Posts: 5
  • Joined: 08-November 11
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 10 November 2011 - 01:05 PM

Thank you very much for your help!
can you do this script also in vbs with the same GUI? plz
@echo off 
cd /d %~dp0 
if not exist "imagex.exe" goto _notexist 
goto _main 
 
:_notexist 
echo. 
echo IMAGEX.EXE executable not found. Please ensure that imagex_capture.cmd  
echo is in the same folder as IMAGEX.EXE before executing this script. 
echo This script will now exit. 
echo. 
pause 
exit 
 
:_main 
if exist "%_ctarget%" set _append=yes 
if not exist "%_ctarget%" set _append=no 
if /i "%_append%"=="yes" set function=Append 
if /i "%_append%"=="no" set function=Capture 
echo. 
echo. 
echo    [I M A G E X   C A P T U R E / A P P E N D   M A I N   M E N U] 
echo. 
echo    1) Specify or change source path, the path you want to capture (e.g. C:\) 
echo       Source: [%_csource%] 
echo. 
echo    2) Specify or change target image to create/append (e.g. d:\myimage.wim) 
if "%_append%"=="yes" echo       *Image will be appended unless you specify a non-existing image file.* 
echo       Target: [%_ctarget%] 
echo. 
echo    3) Specify or change unique description of your image (e.g. Vista Backup) 
echo       Description: [%_descript%] 
echo. 
echo    4) Specify or change FLAG of your image (e.g. ULTIMATE) 
echo       FLAG: [%_FLAG%] 
echo. 
echo    5) Specify or change compression type (MAXIMU, FAST, NONE) 
echo       Compression: [%_compr%] 
echo. 
if "%_csource%" == "" goto _menu1 
if "%_ctarget%" == "" goto _menu1 
if "%_descript%" == "" goto _menu1 
if "%_append%" == "yes" goto _skipcapture 
if "%_FLAG%" == "" goto _menu1 
if "%_compr%" == "" goto _menu1 
:_skipcapture 
echo    6) %function% your image now when ready 
echo       From [%_csource%] To [%_ctarget%] 
echo. 
 
:_menu1 
echo    Q) Quit.  R) Reset all variables 
echo. 
 
:_mainch 
set _ok= 
set /p _ok=Enter your choice:  
if "%_ok%" == "1" goto _getsrc 
if "%_ok%" == "2" goto _gettarget 
if "%_ok%" == "3" goto _getdescript 
if "%_ok%" == "4" goto _getFLAG 
if "%_ok%" == "5" goto _getcompr 
if "%_ok%" == "6" goto _capture 
if /I "%_ok%" == "q" goto _end 
if /I "%_ok%" == "r" goto _reset 
goto _mainch 
 
 
:_getsrc 
set _ok= 
echo. 
echo Specify location of source to capture as a .wim image. 
echo Usually, this would be the root of a drive, such as C:\. 
echo. 
set /p _ok=Enter Source path:  
if exist "%_ok%" ( 
        setx _csource %_ok% 
        set _csource=%_ok% 
) else ( 
        echo. 
        echo --------------------------------------- 
        echo Error: The path "%_ok%" does not exist. 
        echo --------------------------------------- 
        goto _getsrc 
) 
 
goto _main 
 
:_gettarget 
set _ok= 
echo. 
echo Specify path and filename to store the target image, such as D:\image.wim. 
echo. 
set /p _ok=Enter Target image path:  
for %%A in (%_ok%) do set _ext=%%~xA && set _path=%%~dpA 
if /I not "%_ext%"==".wim " ( 
        echo. 
        echo ----------------------------------------------------- 
        echo Error: The filename entered is not a valid .wim file. 
        echo ----------------------------------------------------- 
        goto _gettarget 
) else ( 
        if exist %_ok% ( 
        set _ctarget=%_ok% 
        setx _ctarget %_ok% 
        set _append=yes 
        setx _append yes 
        goto _main 
) else ( 
        if not exist %_path% ( 
        echo. 
        echo ----------------------------------------------------- 
        echo Path does not exist. Please input a valid path again. 
        echo ----------------------------------------------------- 
        goto _gettarget 
  ) else ( 
        setx _ctarget %_ok% 
        set _ctarget=%_ok% 
        set _append=no 
        setx _append no 
        goto _main 
  ) 
) 
) 
 
:_getcompr 
set comp = 
echo. 
echo Please select compression type. 
echo. 
echo    1 for MAXIMUM 
echo    2 for FAST 
echo    3 for NONE 
echo. 
set /p type=Enter compression type:  
if %type%==1 set _compr=MAXIMUM&& setx _compr MAXIMUM 
if %type%==2 set _compr=FAST&& setx _compr FAST 
if %type%==3 set _compr=NONE&& setx _compr NONE 
 
goto _main 
 
:_getFLAG 
set _ok= 
echo. 
echo Specify image FLAG (without quotes). 
echo. 
set /p _ok=Enter FLAG:  
set _FLAG=%_ok% 
setx _FLAG %_ok% 
 
goto _main 
 
:_getdescript 
set _ok= 
echo. 
echo Type description of image (without quotes). 
echo. 
set /p _ok=Enter description:  
set _descript=%_ok% 
setx _descript "%_ok%" 
goto _main 
 
:_capture 
echo. 
if "%_append%"=="yes" goto _appendimage 
echo Ready to capture image from source %_csource% and store image to file 
echo %_ctarget% using compression type %_compr%. 
echo. 
pause 
echo. 
@echo on 
imagex.exe /capture "%_csource%" "%_ctarget%" "%_FLAG%" "%_descript%" /COMPRESS %_compr% 
@echo off 
pause 
goto _end 
 
:_appendimage 
echo. 
echo Ready to append image from source %_csource% and store image to file 
echo %_ctarget%. 
echo. 
pause 
echo. 
@echo on 
imagex.exe /append "%_csource%" "%_ctarget%" "%_descript%" 
@echo off 
pause 
echo. 
goto _end 
 
:_reset 
set _csource= 
set _ctarget= 
set _descript= 
set _compr= 
set _FLAG= 
set _append= 
goto _main 
 
:_end



10x a lot man

#10 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 10 November 2011 - 01:20 PM

Your exiting file suggested that there was likely a missing 'closing bracket', I took a quick look and noticed it almost immediately.

It has now been fixed, please re-copy/paste it!

Please also bear in mind that the file you posted, and the newer one, is not very well designed/structured. For instance, just because something has a .wim extension doesn't make it a valid wim image, but your script is validating only by extension.

#11 User is offline   mchipser 

  • Junior
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 19-February 08

Posted 10 November 2011 - 10:07 PM

View PostYzöwl, on 10 November 2011 - 01:20 PM, said:

Your exiting file suggested that there was likely a missing 'closing bracket', I took a quick look and noticed it almost immediately.

It has now been fixed, please re-copy/paste it!

Please also bear in mind that the file you posted, and the newer one, is not very well designed/structured. For instance, just because something has a .wim extension doesn't make it a valid wim image, but your script is validating only by extension.



What command can you use to verify it is a valid wim? /check?

When we pull our images to our NAS it automatically adds the /verify switch.. Is this enough? Should we add a /check when we push these images back?

#12 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,726
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 11 November 2011 - 09:25 AM

Well Imagex will know for sure if it is a WIM file. However you'd want to put in that check only to make sure it is a valid WIM file before having Imagex deploy it and save yourself an error. To do a real check you'll need to make some DLL calls, but most people just use Gimagex component for this rather than figuring it out from scratch.

#13 User is offline   yweiss 

  • Group: Members
  • Posts: 5
  • Joined: 08-November 11
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 12 November 2011 - 11:45 AM

Hello again
someone can help me to make the batch script for capture the .wim file to a Autiit GUI ?
and also GUI with buttons that if i press on it it will start the aimagex_gui.exe apply and the imagex_gui_compress.exe ?

10x a lot!!

#14 User is offline   iamtheky 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 866
  • Joined: 11-November 08

Posted 12 November 2011 - 12:59 PM

Quote

the batch script for capture the .wim file to a Autiit GUI



Assuming you have autoit and Scite already downloaded: I would recommend copying chipsers script and going line by line hitting F1 until you understand what its doing. If you have questions about anything in particular I am sure you will get plenty of help (but I am very cynical and beginning to think you did not write nor completely understand the batch in the original post as you keep asking for the same thing in different forms like it matters).

This post has been edited by iamtheky: 12 November 2011 - 01:00 PM


#15 User is offline   Ponch 

  • MSFN Master
  • Group: Patrons
  • Posts: 2,965
  • Joined: 23-November 05
  • OS:none specified
  • Country: Country Flag

Posted 14 November 2011 - 01:41 AM

View Postiamtheky, on 12 November 2011 - 12:59 PM, said:

beginning to think you did not write nor completely understand the batch in the original post

"Using this great batch script" usually means you're thankfull to the one who wrote it. :D

#16 User is offline   iamtheky 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 866
  • Joined: 11-November 08

Posted 14 November 2011 - 07:21 AM

inferences of gratefulness aside,

still stands that i believe OP is looking for another finished product, without a solid grasp of what is occurring within.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy