Jump to content











Photo

Define %CDDrive%


  • Please log in to reply
No replies to this topic

#1 RoyM

RoyM

    Frequent Member

  • .script developer
  • 420 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 17 August 2010 - 01:27 AM

(How To)
Define %CDDrive%
This was intended to be used with nativeEX_Win7 (Joshua's Project)
With minor changes can be used to define drive in any project.

Files Needed; ExpEnvVar_x86.exe, ExpEnvVar.txt, Setenv.exe, shortcuts.exe, cddrive.cmd

Open Shell & Config.script in Winbuilder
Make new folder in Attachments (cddrive)
Add "Files Needed" to new folder (cddrive)
Add next line to [Interface] Section
pCheckBox5="USE cddrive.cmd TO BOOT PE, THEN CALL WIN7PELDR ",1,3,1,218,339,22,True
Add next line to [Process] Section
ExtractAllFiles,"%ScriptFile%","cddrive","%Target_Sys%"

If using Z-BaseBuildEx.script you will have to active and rebuild for
cddrive.cmd to be included in build.

*** Note; if using XShortcuts.script, you may wil need to comment out the following lines;

// If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTDelLine,"%TargetDir%\windows\system32\winpeshl.ini","explorer.exe"
// If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","#$qShortcuts.exe -f %SystemDrive%\Windows\System32\Win7PE.cfg#$q","Append"
// If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","#$qShortcuts.exe -f %CDDrive%\Win7PE.cfg#$q","Append"
// If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","explorer.exe","Append"
*** Notes
## ******************* ABOVE LINES ARE RAN FROM CDDRIVE.CMD *****************************************************************

*** In Shell&Config.script Change following lines;

TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","[LaunchApps]","Append"
If,"%Shell%",Equal,"Explorer",If,%CopyPreLogonFiles%,Equal,True,Run,%ScriptFile%,SetupReg.AddReg
## cddrive.cmd can be run with the following line or the one above with hiderun thats commented out.
If,"%Shell%",Equal,"Explorer",If,%pCheckBox5%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","cddrive.cmd","Append"
If,"%Shell%",Equal,"Explorer",If,%pCheckBox5%,Equal,False,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","win7peldr.exe","Append"
If,"%Shell%",Equal,"Explorer",If,%pCheckBox5%,Equal,False,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","explorer.exe","Append"
##

Contents of ExpEnvVar.txt;
"HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment,CDDrive"
"HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment,Path"

Contents of cddrive.cmd;

@ECHO OFF
Title "** DON'T CLOSE ME ** - CDDrive.cmd Defines PEDrive "
ECHO.
ECHO " Starting Win7Peldr..."
win7peldr.exe
SET CDTAG1=SOURCES\BOOT.WIM
SET CDDrive=
@ECHO All
@ECHO Available
@ECHO Drives;
for %%a in (C 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:\nul ECHO %%a )
for %%a in (C 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:\%CDTAG1% ECHO %%a:\%CDTAG1% EXISTS)
for %%a in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do (if exist %%a:\%CDTAG1% SET CDDrive=%%a)
ECHO.
ECHO.
ECHO CDDrive Found = %CDDrive%
SET CDDrive=%CDDrive%:
set Path=%Path%;%CDDrive%\
SETENV -m CDDrive %CDDrive%
SETENV -m Path %Path%
BroadcastEnvChange.exe /broadcast
ECHO " Creating Shortcuts..."
Shortcuts.exe -f %SystemDrive%\Windows\System32\Win7PE.cfg
Shortcuts.exe -f %CDDrive%\Win7PE.cfg
ECHO.
ECHO.
cls
COLOR 1F
ECHO.
ECHO. SystemRoot = %SystemRoot%
ECHO CDDrive = %CDDrive% windir = %windir%
ECHO SystemDrive = %SystemDrive% Temp = %Temp%
ECHO USERNAME = %USERNAME% Tmp = %Tmp%
ECHO.
ECHO.
ECHO #######################################
ECHO # #
ECHO # (Do Not Close This Window) #
ECHO # #
ECHO # ** MINIMIZE ONLY ** #
ECHO # #
ECHO #######################################
ECHO.
ECHO.
ECHO.
ECHO.
ECHO Path:
ECHO %Path%
explorer.exe
:: END ***********************************************************************

It's been so long since I've applied this fix to my build that I can't remember, nor do I still
have original Winbuilder scripts, So everything should be here for a working tweak.

If not using Xshortcuts.script comment out the lines with shortcuts.exe in them.

What you will get from this tweak is;
%CDDrive% is now defined in the registry and the path correctly under this Registry location.
"HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment"
There will be a Dos Box on your desktop that if terminated will reboot your PE
If you don't like the Dos Box on your desktop change these lines;
From:
If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","cddrive.cmd","Append"
To:
If,"%Shell%",Equal,"Explorer",If,%pCheckBox1%,Equal,True,TXTAddLine,"%TargetDir%\windows\system32\winpeshl.ini","#$qhiderun.exe /w cddrive.cmd#$q","Append"
hiderun.exe=308K (MEMORY USED)
CMD.EXE=604K (MEMORY USED)

Also a little trick I use when building my PE:
If you see my Taskbar Tutorial, http://www.boot-land...showtopic=12249
I state that I don't use win7peldr.exe to make my shortcuts.
there is nothing under my [shortcut] sections in Win7PE.cfg
I include it in my build for testing new scripts and so on.

When I make my shortcuts as seen in Taskbar Tutorial, I create
my Shortcuts in VM and then include them in my scripts;
Heres a short excerpt;

Edit shortcut\properties\target;
Change target to point to original
%CDDrive%\Programs\%ProgramFolder%\%ProgramEXE%

Edit shortcut\properties\start in;
Change start in to point to original
%CDDrive%\Programs\%ProgramFolder%

I will use E: as my %CDDrive%, and Notepad++.script for example:
After I include the script in my build, I then
open it in VM and navigate to E:\Programs\Notepad++
Then I create a shortcut to Notepad++.exe which is created
on the desktop for me. When I edit the shortcut properties
this is what would actually be in the Target and Start In Boxes.

target = E:\Programs\Notepad++\Notepad++.exe
start in = E:\Programs\Notepad++

I edit them as folows;
target = %CDDrive%\Programs\Notepad++\Notepad++.exe
start in = %CDDrive%\Programs\Notepad++
Change Icon = %SystemRoot%\system32\Notepad++.ico
*** Notepad++.ico is icon I extracted from Notepad++.exe
*** and Extract into \system32 directory via Notepad++.script
I then Apply and save, then 7zip the shortcut
to %ProgramTitle%.7z and include into my scripts

This will ensure that no matter What Letter get's
assigned to %CDDrive%, your icons will display and
work properly, I have tested All the way up to H:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users