Jump to content

Unattended Secret: Set Variable From File


gosh
 Share

Recommended Posts

One item on my unattended "wish list" has been to have the ability to put the cd name and version number in 1 file, and have my unattended cd look at the file for the cd name and version.

For example, take my last cd:

The html autorun had the cd name and version twice. My apps.bat has the cd version number in it for logging. I also have the cd name and version in the cd boot menu. One common problem is remembering to change the cd name and version in every place of my unattended cd before i burn it. In the past i've forgotten to change the cd version and name in my autorun and boot menu. Nothing is more annoying, then spending months on an unattended cd but having the wrong name or version on the boot menu!

This is not a new concept. Recently for longhorn microsoft champed my idea. See here.

I spent months searching for an answer, finding instead many dead roads. One idea was to make an .xml file that could be accessed via html. The problem is my cd boot menu doesn't use html. One of the hardest things to do is to load text from a file and set it as a variable.

Finally i found this method. I haven't had time to fully test it, but it seems like a champ.

Here is my current winpesetup.bat file. More about this file later. As you can see it's a work in progress, so expect some of the code to be incomplete or not make sense. This file is awesome.

winpesetup.bat

@ECHO OFF

REM

REM PRE

REM

:getcd

IF EXIST C:\cd.ver set CDROM=C:

IF EXIST D:\cd.ver set CDROM=D:

IF EXIST E:\cd.ver set CDROM=E:

IF EXIST F:\cd.ver set CDROM=F:

IF EXIST G:\cd.ver set CDROM=G:

IF EXIST H:\cd.ver set CDROM=H:

IF EXIST I:\cd.ver set CDROM=I:

IF EXIST J:\cd.ver set CDROM=J:

IF EXIST K:\cd.ver set CDROM=K:

IF EXIST L:\cd.ver set CDROM=L:

IF EXIST M:\cd.ver set CDROM=M:

IF EXIST N:\cd.ver set CDROM=N:

IF EXIST O:\cd.ver set CDROM=O:

IF EXIST P:\cd.ver set CDROM=P:

IF EXIST Q:\cd.ver set CDROM=Q:

IF EXIST R:\cd.ver set CDROM=R:

IF EXIST S:\cd.ver set CDROM=S:

IF EXIST T:\cd.ver set CDROM=T:

IF EXIST U:\cd.ver set CDROM=U:

IF EXIST V:\cd.ver set CDROM=V:

IF EXIST W:\cd.ver set CDROM=W:

IF EXIST X:\cd.ver set CDROM=X:

IF EXIST Y:\cd.ver set CDROM=Y:

IF EXIST Z:\cd.ver set CDROM=Z:

setx "mycdrom" %CDROM% -m

:getcdversion

FOR /F "tokens=*" %%a in (%mycdrom%\cd.ver) Do CALL :makecd %%a

Goto :EOF

:makecd

SET cdver=%*

@ECHO.

@ECHO.

@ECHO.

ECHO                 Welcome to %cdver%

@ECHO.

@ECHO.

@ECHO.

ECHO      Please chose your installation method below:

@ECHO.

@ECHO.

ECHO      1)  Automated

ECHO      2)  Customized

@ECHO.

@ECHO.

ECHO      h)  Show help file

pause

:EOF

ECHO There was an error running the script >> %tmp%\winpesetup.log

REM

REM Make settings.reg to save environment variables for apps.bat

REM

ECHO REGEDIT4  >> %tmp%\settings.reg

@ECHO.         >> %tmp%\settings.reg

ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]  >> %tmp%\settings.reg

ECHO %mycdrom% >> %tmp%\settings.reg

ECHO %cdver% >> %tmp%\settings.reg

REM

regedit /s %tmp%\settings.reg

Ok, this might seem complicated but it's really not. End user runs my cd, and is presented with winpesetup.bat. The file first sets up the menu by setting the cdrom as a variable to be used later. The menu then loads the contens of cd.ver and sets it as a variable. In this case, cd.ver has the cd name and version. Make cd.ver and put whatever you want in it and run my winpesetup.bat, you'll see what i mean.

As far as winpesetup.bat goes, i'm gonna run it from winpe and within the windows GUI, presenting a common interface. Since my cd installs windows from winpe, it bypasses the problem of my xp boot menu not using variables. You could use this variable anytime during setup, such as in apps.bat This accomplishes my goal of setting the cd name and version once. Winpesetup.bat is very complicated; im gonna use a ramdrive and save inputed varibles to a registry file and apps.bat will import it. Once winpesetup.bat is done i'll more fully explain it's role in my unattended cd.

Enjoy,

-gosh

Edited by Drewdatrip
Link to comment
Share on other sites

  • 5 years later...

Very nice idea.

Little question:

Is it right, that this systemvariable is set for alway from now on?

How can i remove this systemvariable from the registry afer finishing of all?

ska

Link to comment
Share on other sites

Very nice idea.

Little question:

Is it right, that this systemvariable is set for alway from now on?

How can i remove this systemvariable from the registry afer finishing of all?

ska

I highly doubt you'll get a response. gosh hasn't been that active on the forums lately. That and the fact that this post was made in 2003...
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...