# Winpe Startnet.cmd to execute CDROM|DVD drive letter



## Urlyin (Jan 9, 2012)

I create images for servers using Winpe AIK in conjuction with Ghost. I install the Windows OS do the SP and updates then sysprep. I capture the image with Ghost and then use Winpe to execute the Ghost image. Now the issue at hand is that the DVD drive is not always default at the drive letter D: so  I use the command lines below. I know there is a better way to write it in the Startnet.cmd file any suggestions?


if EXIST D:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=D:\image\image,dst=1 -sure -rb

if EXIST E:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=E:\image\image,dst=1 -sure -rb

if EXIST F:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=F:\image\image,dst=1 -sure -rb

if EXIST G:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=G:\image\image,dst=1 -sure -rb

if EXIST H:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=H:\image\image,dst=1 -sure -rb

if EXIST I:\image\image.gho x:\windows\ghost\ghost32.exe -clone,mode=restore,src=I:\image\image,dst=1 -sure -rb


----------



## Solaris17 (Jan 9, 2012)

hmmmmmm maybe you could instead call a batch file that inturn calls the image?

and simply put something like %CDROM% or try calling it with commas

a, b, c, d, etc that way you only have one line? (via batch)


----------



## Drone (Jan 9, 2012)

Urlyin said:


> x:\windows\ghost\ghost32.exe


You can use environment variable so:
%windir%\ghost\ghost32.exe ...



Solaris17 said:


> and simply put something like %CDROM% or try calling it with commas
> a, b, c, d, etc that way you only have one line?



There isn't an environment variable for the CDROM, but you can set one yourself. You can put some special file on that cd (in this case it's image.gho) and use *if* operator to check if file is there then cdrom is set with its corresponding letter:

*@echo off
for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\image\image.gho set CDROM=%%a*


----------



## Solaris17 (Jan 9, 2012)

Drone said:


> You can use environment variable so:
> %windir%\ghost\ghost32.exe ...
> 
> 
> ...




haha thats the command i was talking about! i just didnt remember how exactly to write it glad you picked up my slack.


----------



## Urlyin (Jan 9, 2012)

Thank you guys.... I'll test it and just set it to Z:


----------



## Raz (Mar 3, 2012)

*CDROM Variable*



Drone said:


> @echo off
> for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\image\image.gho set CDROM=%%a



It is what I wanted. I am woundering how to use this code should have to put in Winpeshl.ini or startnet.cmd.

I pust it in startnet.cmd file of PE like this.

for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\image\image.gho set CDROM=%%a
X:\Program Files\Ghost11-2010\ghost32.exe -clone,mode=pload,src=%CDROM%\RECOVERY\RECOVERY.gho:1,dst=1:2

It did not work.

Then I tried and put the code in winpeshl.net file  of PE like this:

[LaunchApp]
for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\image\image.gho set CDROM=%%a
AppPath=X:\Program Files\Ghost11-2010\ghost32.exe -clone,mode=pload,src=%CDROM%\RECOVERY\RECOVERY.gho:1,dst=1:2

In non of the above system was able to find \RECOVERY\RECOVERY.gho in CD drive or Hard drive.

I believe I am doing some thing wrong. Could you please write me how do that.

Many thanks


----------



## MBManiac (May 18, 2012)

Try making the following changes in blue:
[LaunchApp]
for %%a in (D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) DO IF EXIST %%a:\image\image.gho (SET CDROM=%%a)
AppPath=X:\Program Files\Ghost11-2010\ghost32.exe -clone,mode=pload,src=%CDROM%*:*\RECOVERY\RECOVERY.gho

I found adding commas between the drive letters, capitalizing letters (not sure if that matters) and adding a colon after your %CDROM% variable might just do the trick.

Also, once your CDROM variable has been established, you might want to go to it and then run your command. Here is a sample of one of my WinPE command files:


@Echo Off
Echo.
Echo Initializing Windows Preinstallation Environment. Please wait...
wpeinit
echo.
for %%a in (C,D,E,F,G,H) DO IF EXIST %%a:\GO.CMD (SET CDROM=%%a)
PATH %CDROM%;%PATH%
%CDROM%:
GO
echo.

Good luck!


----------

