Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Need help automating WinPE Ghost recovery

Created: 02 Oct 2012 • Updated: 04 Oct 2012 | 10 comments

Hi,

I'm still running Symantec Ghost Solution Suite 11.5.  I've been creating bootable DOS USB sticks for re-imaging my computer using ghost.exe, via the Symantec Ghost Boot Wizard.

Because it's DOS, its terribly slow, but I do have it scripted such that I just plug the stick in, set the USB stick as the boot device, and the rest is automatic.

In an attempt to speed up the re-imaging process, I started playing with WinPE.  I am able to create a bootable USB stick, boot into a WinPE environment, and have the ghost32.exe launch automatically. BUT, I still have to select the image file, and the destination disk manually.  The speed is majorly improved (reduced imaging time from 35 min to 9)

I attempted to automate the image file selection by modifying the start.bat file in the ghost folder of the USB stick, but no luck.  So, here I am asking for your advice!

With DOS, I would just add the following to my autoexec.bat file, and the system would automatically re-image my HDD:

GHOST.EXE -clone,mode=restore,src=C:\ghost\win7recovery1.gho,dst=2 -sure

Are there any ghost gurus out there that can point me in the right direction to get the same effect from a WinPE boot?

Thanks!

Comments 10 CommentsJump to latest comment

CraigV's picture

...moved to the correct forum!

Alternative ways to access Backup Exec Technical Support:

https://www-secure.symantec.com/connect/blogs/alte...

EdT's picture

What I would suggest if you have the time to develop it, is an automatic solution which can identify your target machine automatically and choose the correct build from a list. When you move to WinPE, you can write code in HTA format which provides a user GUI, and which also supports vbscript and WMI code. WinPE also supports WMI code if the option is installed, and WMI is able to retrieve full information about the connected system. In my solution, I edited the startnet.cmd in my solution so that it would locate and run an HTA file in the root of my USB boot drive, so I could update the image library at any time to support additional machines.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

ccargin's picture

OK, I edited the startnet.cmd, recaptured the boot.wim, and copied the new boot.wim to the usb drive.   The new startnet.cmd looks like this:

echo off
if exist c:\ghost\unattend.xml (
wpeinit /unattend=c:\ghost\unattend.xml
) else if exist x:\ghost\unattend.xml (
wpeinit /unattend=x:\ghost\unattend.xml
) else (
wpeinit

set path=%path%;x:\ghost
x:
cd \ghost
ghost32.exe /setosdrives /blind >> x:\ghost\startlog.txt
start ghost32.exe  -clone,mode=restore,src=C:\Win7recovery1.gho,dst=2 -sure
)

BUT, the system is doing the same thing as before...it opens ghost, but does not execute the restore of the Win7recovery.gho to disk 2.  I am relying on the similar commands I used in DOS (start ghost32.exe -clone,mode=restore,src=C:\Win7recovery1.gho,dst=2 -sure) is this the problem?

Ed - I see your advice as my next step, I just need to figure out this first hurdle, then I can add functionality.

ccargin's picture

just an update, I'm still looking for advice for WinPE.  BUT, I came up with a pretty slick solution using Windows 8-to-go that appears to be just as fast.

I created a bootable USB Windows 8 stick (Windows 8 to go), and have a shortcut with the parameters listed above to ghost32.exe tagged onto the Start screen.  It's not quite hands off imaging I was targeting, but it's one click imaging!

I even added -rb at the end, so when it's done, it reboots to the drive I just imaged!

EdT's picture

Are you sure that the image source is on C: ?

If WinPE is mounting drives in a different order than the one you are expecting, then the code is not going to work.

Best thing to do is to get to the WinPE command prompt, and check what is on the C: drive and whether your target is the second drive or not.

You need to bear in mind that WinPE mounts drives based on their HARDWARE order, whereas windows can boot from any drive that has an active partition and the necessary boot files. So for example you could have a system with an old IDE drive and a SATA drive which boots windows from the SATA drive. However, at the bios level, IDE drives are mounted ahead of SATA drives, so whereas Windows will mount the SATA drive as drive C, WinPE will mount the IDE drive as drive C.

Consequently, when I am using batch scripts under WinPE, I look for specific marker files on any source drives with images, so that I can check each drive letter in sequence until I find the right one.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

ccargin's picture

OK, I got sidetracked for a couple of weeks, but I'm back on the project.

I was able to get a USB bootable WinPE, and automate the re-imaging process.

Everything worked great when re-imaging drives, because they show up as the C: drive, and the USB shows up as the D: drive.

BUT, as I discovered today, when installing a brand new, not initialized drive, it does not show up as C: and thus the USB winds up showing up as C:, which causes my -clone,mode=restore,src=D:\Win7.gho,dst=1 -sure -rb to fail, because the USB is no longer the D drive.

So, back to your point, EdT, about using batch scripts to look for marker files...could you shed some light onto how you do that?

Currently, I am just trying to image one model of PC from one specific ghost file.  Eventually, I want to be able to image 3-4 different models using 3-4 (or more) image files.  (Each model has a unique image file, and if there are multiple OS, then each model will have multiple image files).

I assume once I am able to make this work for one unit, then I can figure out how to add a menu to choose which image to deploy.

As always, any help is appreciated!

Thanks

EdT's picture

Looking for marker files in a batch script - the example below was for an external backup process, but I'm sure you will get the idea:

@ECHO OFF
IF EXIST D:\XXFLAGXX.TXT GOTO D
IF EXIST E:\XXFLAGXX.TXT GOTO E
IF EXIST F:\XXFLAGXX.TXT GOTO F
IF EXIST G:\XXFLAGXX.TXT GOTO G
IF EXIST H:\XXFLAGXX.TXT GOTO H
IF EXIST I:\XXFLAGXX.TXT GOTO I
IF EXIST J:\XXFLAGXX.TXT GOTO J
IF EXIST K:\XXFLAGXX.TXT GOTO K
IF EXIST L:\XXFLAGXX.TXT GOTO L
IF EXIST M:\XXFLAGXX.TXT GOTO M
IF EXIST N:\XXFLAGXX.TXT GOTO N
IF EXIST O:\XXFLAGXX.TXT GOTO O
IF EXIST P:\XXFLAGXX.TXT GOTO P
IF EXIST Q:\XXFLAGXX.TXT GOTO Q
IF EXIST R:\XXFLAGXX.TXT GOTO R
IF EXIST S:\XXFLAGXX.TXT GOTO S
IF EXIST T:\XXFLAGXX.TXT GOTO T
IF EXIST U:\XXFLAGXX.TXT GOTO U
IF EXIST V:\XXFLAGXX.TXT GOTO V
IF EXIST W:\XXFLAGXX.TXT GOTO W
IF EXIST X:\XXFLAGXX.TXT GOTO X
IF EXIST Y:\XXFLAGXX.TXT GOTO Y
IF EXIST Z:\XXFLAGXX.TXT GOTO Z
ECHO EXTERNAL DEVICE NOT FOUND - BACKUP PROCESS ABORTED!
GOTO END
:D
D:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "D:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:E
E:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "E:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:F
F:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "F:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:G
G:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "G:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:H
H:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "H:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:I
I:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "I:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:J
J:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "J:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:K
K:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "K:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:L
L:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "L:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:M
M:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "M:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:N
N:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "N:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:O
O:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "O:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:P
P:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "P:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:Q
Q:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "Q:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:R
R:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "R:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:S
S:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "S:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:T
T:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "T:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:U
U:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "U:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:V
V:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "V:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:W
W:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "W:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:X
X:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "X:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:Y
Y:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "Y:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
:Z
Z:
CD\
CD ROBOCOPY
ROBOCOPY "C:\Users\Sarah" "Z:\Sarah" /E /PURGE /xd "System Volume Information" /xd Recycler /xd Recycled /R:0 /W:0
GOTO END
 
 
:END
ECHO.
ECHO.
ECHO PRESS ANY KEY TO CONTINUE
PAUSE
 
When it comes to multiple images and multiple models, you can use WMI under WinPE to detect the chassis and choose the appropriate image from your library. You can make it as automatic as you want, or alternatively build an HTA based GUI that runs under WinPE, and can give the technician a number of choices.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

ICHCB's picture

How about this approach?

Setting a simple variable by searching for the existance of files on your usb drive in my case I searched to see if windrivers was there and if so called that device USB and could call to it by %USB%

I had some issues getting deployanywhere to work but after I put in a boot.txt in the root of the ghost image I just restored then when I scan for boot.txt it sets that device (the freshly restored drive) as BOOT and I can call to it by calling %BOOT%

rem --- finding USB drive
for %%f in (C D E F G H I J K L M N O P Q R S) do if exist %%f:\Windrivers set USB=%%f:

set path=%path%;%USB%\ghost

%USB%
cd \ghost

rem --- This will create primary OS drive configuration ---
ghost32.exe /setosdrives /blind >>%USB%\ghost\startlog.txt

rem --- Ghost Command to restore image.gho
Ghost32 -clone,mode=restore,src=%USB%\data\image.gho,dst=1 -batch -fx

rem --- Windows variable
for %%f in (C D E F G H I J K L M N O P Q R S) do if exist %%f:\Windrivers set USB=%%f:
for %%f in (C D E F G H I J K L M N O P Q R S) do if exist %%f:\boot.txt set BOOT=%%f:

rem --- DeployAnywhere command
ghdplyaw32.exe /target=%BOOT%\Windows /DDB=%USB%\WINDRIVERS

rem --- The win PE reboot command
wpeutil reboot

If you find this post helpful please give it a thumbs up!
If you find that this solves your problem please mark it as the solution! 

EdT's picture

Looks like a much more elegant script than mine!

Thanks!

EdT

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.