my44186680 Posted September 13, 2007 Posted September 13, 2007 The codes are as below:when I try to load a new machine by ghosting from image, I use the command:ghost -clone, mode=load,src=X:\Backup.gho,dst=1 -ntil -sure -autothen followed the below codesSET E=FOR %%! IN (1 2) DO IF ERRORLEVEL %%!00 SET E=%%!SET !=0 1 2 3 4 5 6 7 8 9IF ERRORLEVEL ?SET !=0 1 2 3 4 5IF ERRORLEVEL : FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%!0 SET E=%E%%%!IF NOT ERRORLEVEL * SET !=0 1 2 3 4 5 6 7 8 9FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%! SET E=%E%%%!IF NOT %E%==0 goto ERRORThe codes can help detect whether the process could be finished successful during ghosting, if we interrput the ghosting process, it really could goto ERROR label.But I don't understand how come that make this happen? Some command or expression I even havenot seen before.Could anyone help me on this ? or provide some links to introduce some information about this. very appreciated.
Yzöwl Posted September 14, 2007 Posted September 14, 2007 From the code you have posted, I cannot understand what it is you are trying to achieve.Is it not just better to inform you of an error if one existed as a result of the previous command.@echo offghost -clone, mode=load,src=X:\Backup.gho,dst=1 -ntil -sure -auto::if errorlevel returned is 1 or greater then go to label named onerrif errorlevel 1 goto onerr::any further code on success hereecho. The operation was successfulpausegoto :eof:onerr::any further code on failure hereecho. The operation failedpause
my44186680 Posted September 17, 2007 Author Posted September 17, 2007 Thanks for your reply. I just don't understand what this means "IF ERRORLEVEL ?SET !=0 1 2 3 4 5"IF ERRORLEVEL : FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%!0 SET E=%E%%%!Errorlevel with ":" I never see this usage.
Yzöwl Posted September 17, 2007 Posted September 17, 2007 You would need to provide the entire file and the ghost documentation on its errorlevels in order for me to attempt to make some working code.Looking at what is there, I've got no idea what is needed only that the entire batch code presented is one of the most meaningless I've ever seen.The producer of the code appears to have no idea whatsoever of what errorlevels are or how they work.
my44186680 Posted September 21, 2007 Author Posted September 21, 2007 (edited) Thanks very much for your kind reply,here is the codes@echo offset version=Beta1set imagefile=test.GHOZ:\gdisk 2 /del /allZ:\gdisk 2 /cre /priZ:\gdisk 1 /del /allZ:\gdisk 1 /cre /priZ:\ghost -clone,mode=PLOAD,src=Z:\%imagefile%:1,dst=1:1 -ntil -auto -sure -fx -PREFGHST -FFX -FFI -FFSSET E=FOR %%! IN (1 2) DO IF ERRORLEVEL %%!00 SET E=%%!SET !=0 1 2 3 4 5 6 7 8 9IF ERRORLEVEL ?SET !=0 1 2 3 4 5IF ERRORLEVEL : FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%!0 SET E=%E%%%!IF NOT ERRORLEVEL * SET !=0 1 2 3 4 5 6 7 8 9FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%! SET E=%E%%%!IF NOT %E%==0 goto ERRORZ:\ghost -clone,mode=PLOAD,src=Z:\%imagefile%:2,dst=2:1 -ntil -auto -sure -fx -PREFGHST -FFX -FFI -FFSrem -fnu -fnaSET E=FOR %%! IN (1 2) DO IF ERRORLEVEL %%!00 SET E=%%!SET !=0 1 2 3 4 5 6 7 8 9IF ERRORLEVEL ?SET !=0 1 2 3 4 5IF ERRORLEVEL : FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%!0 SET E=%E%%%!IF NOT ERRORLEVEL * SET !=0 1 2 3 4 5 6 7 8 9FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%! SET E=%E%%%!IF NOT %E%==0 goto ERRORgoto END:ERRORecho.echo The Ghosting process has failed!!!goto QUIT:END:QUITThat's the entire code,it is working for machines with 2 harddisks. When ghosting process is interrupted by Ctrl+C or other methods, the codes can detect this ,and turn to :error label. Edited September 21, 2007 by my44186680
Yzöwl Posted September 21, 2007 Posted September 21, 2007 The entire errorlevel section is a pointless waste of space, as I stated in my first response all you need to do is replace both of the sections containingSET E=FOR %%! IN (1 2) DO IF ERRORLEVEL %%!00 SET E=%%!SET !=0 1 2 3 4 5 6 7 8 9IF ERRORLEVEL ?SET !=0 1 2 3 4 5IF ERRORLEVEL : FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%!0 SET E=%E%%%!IF NOT ERRORLEVEL * SET !=0 1 2 3 4 5 6 7 8 9FOR %%! IN (%!%) DO IF ERRORLEVEL %E%%%! SET E=%E%%%!IF NOT %E%==0 goto ERRORwithif errorlevel 1 goto ERRORorif not errorlevel 0 goto ERRORAll you are in effect doing is letting them know that an error occurred.Also if they needed to see that error message you would need to either be running in a pre-opened console window or add a command to pause the end before the window closed without reading it.Another thing you may or may not be aware of is that if an error of any sort occurs whilst performing the clone of image 1 onto your first disk, the script will not even bother cloning the other image to the second disk.
my44186680 Posted September 24, 2007 Author Posted September 24, 2007 Oh, it is amazing, I will replace the codes with your post, and have a test. Thank you very much for your help, actually I have been confused for this a long time.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now