Jump to content

Recommended Posts

Posted

Thought I would pass this along. This is how I'm handling installing apps on the CD ... Originally I had each one in it's own directory, and would put in all the proper commands in RunOnceEx.cmd, called from cmdlines.txt in $OEM$.

That got to be a hassle - every time I wanted to add or move the order of an app. So, now it goes like this :

In the Apps\ folder on the CD source tree, create a folder for each application you want to install. They should be named as follows

206.WinRAR

That is, a number, a dot, and a name. No other dots, no spaces etc in the directory name. The number is the order if installation in the RunOnceEx tree structure, so moving apps around in order is just a matter of renaming the dir to a new number.

RunOnceEx.cmd contains the following :

@Echo Off

FOR %%i 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 %%i:\win51ip.SP2 SET CDROM=%%i:
SET PP=%cdrom%\Apps\
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Programs" /f

%CDROM%
cd %PP%
for /D %%i in (*) do %%i\installit.cmd %%~ni %PP%%%~ni%%~xi %KEY%
for /D %%i in (*) do REG ADD %KEY%\%%~ni /V 99 /D "%PP%%%i\finishup.cmd"

exit

This changes to the Apps directory on the CD, then enumerates every directory there in order of the numbers. It calls a standard batch file installit.cmd for each one and passes it 3 parameters ...

  1. Number - this is the numerical part of the directory name
  2. Path - this is the full path to the directory, including drive
  3. Key - the registry key root to install to

%%~ni resolves to the number of the app

%%~xi resolves to the name of the app

It then inserts a call to the finishup.cmd file at position 99 for each numbered directory. That batchfile contains any cleanup you need to do - removing spurious shortcuts, adding registry entries, etc.

In each directory you have the installit.cmd file and any other files you need to silently install the application. installit.cmd contains the following (for WinRARas example)

@echo off

set NUM=%1
set DIR=%2
set KEY=%3

REG ADD %KEY%\%NUM% /VE /D "WinRAR v3.5 Corporate" /f
REG ADD %KEY%\%NUM% /V 1 /D "%DIR%\winrar_350_CE.exe /S" /f

This inserts the appropriate commands to install the app in the numerical order you select by virtue of the name of the directory. In this case, WinRAR will be installed via key #206. Just change it from 206.WinRAR to 234.WinRAR to move it's installation order.

There are a couple of things to be done for WinRAR once installed, so those commands go into the finishup.cmd file in the 206.WinRAR directory. In my case, it contains :

move "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\WinRAR" "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\Accessories"
rd /s /q "%systemdrive%\Documents and Settings\Administrator\Start Menu\Programs\WinRAR"

It's also easy to remove apps - just move the directory out of Apps. No need to go edit RunOnceEx.cmd. Each application is a self-contained directory, so changes you make to one won't affect another. Making a custom CD is really easy now - just drag the apps you want in and out of the Apps directory in your CD source, then gen the image. No edits, nothing :)

D.


Posted

Hrm - this is a little odd. I'm sometimes seeing that a cmd file doesn't actually run. For example, the RunOnceEx.cmd sets up all the individual sections for all the apps as shown above.

My two files for WinRAR are like this :

installit.cmd

@echo off

set NUM=%1
set DIR=%2
set KEY=%3

REG ADD %KEY%\%NUM% /VE /D "WinRAR v3.5 Corporate" /f
REG ADD %KEY%\%NUM% /V 1 /D "%DIR%\winrar_350_CE.exe /S" /f

and finishup.cmd

@echo off

move "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\WinRAR" "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\Accessories"

rd /s /q "%systemdrive%\Documents and Settings\Administrator\Start Menu\Programs\WinRAR"

I've noticed that for a few apps, the finishup.cmd doesn't run. The actual code I'm using for RunOnceEx.cmd is this :

@Echo Off

FOR %%i 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 %%i:\win51ip.SP2 SET CDROM=%%i:
SET PP=%cdrom%\Apps\
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Programs" /f

%CDROM%
cd %PP%

rem **********************************
rem * Using 213.PeerGuardian v2 as example directory
rem * %%~ni resolves to numerical part of directory name = 213
rem * %%~xi resolves to extentions after . of dir name = .PeerGuardian v2
rem * %PP% resolves to location on CD of all apps = d:\apps\
rem *
rem * So parameters passed to installit.cmd in each directory are :
rem * 1 ___________2__________ ____3__________
rem * / \ / \ / \
rem * 213 d:\apps\213.PeerGuardian HKLM\SOFTWARE....
rem *
rem * NOTE! No dots or spaces in directory name aside from number separator !!
rem * 213.PeerGuardian-V2 is OK
rem * 213.PeerGuardian.V2 is Verboten !
rem * 213.PeerGuardian V2 is Verboten !
rem **********************************
for /D %%i in (*) do (
%%i\installit.cmd %%~ni %PP%%%i %KEY%
if exist "%PP%%%i\finishup.cmd" REG ADD %KEY%\%%~ni /V 99 /D "%PP%%%i\finishup.cmd %PP%%%i"
)

REG EXPORT %KEY% "%systemdrive%\RunOnceEx-install.txt"

EXIT

Note the reg export at the bottom - I want to see the entire RunOnceEx tree. But this doesn't actually save it. There is no c:\RunOnceEx-install.txt file generated. It works fine in a batchfile on it's own afterwards. That is, I create a few entries, then run a one-liner with the reg export in it, and it produces the expected file with the expected tree. But it doesn't seem to work when run from RunOnceEx.cmd, as called by cmdlines.txt.

So, any ideas ?

D.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...