using environ. variable data to create a new value in a .reg file

using environ. variable data to create a new value in a .reg file

Post by k » Sun, 01 Jun 2003 06:46:56



I need to do the following in either reg.exe or a .reg file...

(This is for an autologon to local machine without an NT domain,
manual logon to Novell BTW.)

I need to use the %computername% environmental variable to make a
change to a couple of values in the registry like so:

HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\WinLogon\DefaultDomainName = (get the current value
for %computername% and use that value here)

I would have preferred to do this with a reg_expand_sz entry in the
first place, but it seems the novell client will not take the
variable. So as it stands now (as a reg_sz entry,)when I distribute my
ghost to my lab machines, renaming the box breaks the autologon...I
guess enabling autologon makes the DefaultDomainName stay the same
even when you change the machine name by normal methods.

here is what I have tried, I am sure it is way off though (cause it
didn't work)

REGEDIT4

[HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]
"test"=echo %computername%

I get nothing by merging the above (or any other combination of "("
"<" or "[" I have tried). I know the basic script works, because I can
do a "test"="testdata" and show up in the right place correctly
displaying the value testdata. I have tried many different variations
using echo and set, but I am not a code-writer and cannot find
examples of doing anything like this anywhere else.

anyone out there know how to do this by any chance?

thanks in advance for any help.

 
 
 

using environ. variable data to create a new value in a .reg file

Post by Mark » Sun, 01 Jun 2003 07:33:40



Quote:> I need to do the following in either reg.exe or a .reg file...

> (This is for an autologon to local machine without an NT domain,
> manual logon to Novell BTW.)

> I need to use the %computername% environmental variable to make a
> change to a couple of values in the registry like so:

> HKLM\SOFTWARE\Microsoft\Windows
> NT\CurrentVersion\WinLogon\DefaultDomainName = (get the current
> value for %computername% and use that value here)

> I would have preferred to do this with a reg_expand_sz entry in
> the first place, but it seems the novell client will not take the
> variable. So as it stands now (as a reg_sz entry,)when I
> distribute my ghost to my lab machines, renaming the box breaks
> the autologon...I guess enabling autologon makes the
> DefaultDomainName stay the same even when you change the machine
> name by normal methods.

> here is what I have tried, I am sure it is way off though (cause
> it didn't work)

> REGEDIT4

> [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]
> "test"=echo %computername%

> I get nothing by merging the above (or any other combination of
> "(" "<" or "[" I have tried). I know the basic script works,
> because I can do a "test"="testdata" and show up in the right
> place correctly displaying the value testdata. I have tried many
> different variations using echo and set, but I am not a
> code-writer and cannot find examples of doing anything like this
> anywhere else.

I suspect what you need to do is use the variable value and
 write it to a .reg file, then merge it
or
 use a tool for direct registry access like reg.exe

  echo REGEDIT4 >modfile.reg
  echo. >>modfile.reg
...
  echo a-long-string-that-is-a-registry-path\valuename=%computername% >>modfile.reg
...

Then regedit /s modfile.reg

 
 
 

using environ. variable data to create a new value in a .reg file

Post by Oli Restoric » Sun, 01 Jun 2003 22:15:12


Mark's suggestion looks good.

I wrote a program to do this a while back.  You can download it from
www.willowhayes.co.uk/download/regvars.exe

-----
Regvars.exe is a utility for scanning registry files (.reg) and replacing
any instances of environment variables with their expanded versions. For
example, if you run a reg file containing %programfiles% through the
program, it will replace all instances of %programfiles% with, for example,
"c:\program files".

Regvars.exe also has an added "virtual" environment variable called %cd%,
which evaluates to the first CD-ROM drive in the system

The syntax is "regvars.exe input.reg output.reg". There is no error checking
for the command line parameters and it's pretty rough and ready, but does
the job.

NB. Regvars.exe current doesn't accept unicode files. The default for a .reg
file is unicode. To overcome this, when saving the input file from regedit,
be sure to select the "95/NT regedit4" option from the save dialogue box.

---------------

You would include the %computername% in your source registry file and run
the regvars.exe program on the destination machine to create a new reg file
with the environment variables expanded.  You can then use "regedit /s" on
the new file to import the registry entries.

Hope this helps

Oli


Quote:> I need to do the following in either reg.exe or a .reg file...

> (This is for an autologon to local machine without an NT domain,
> manual logon to Novell BTW.)

> I need to use the %computername% environmental variable to make a
> change to a couple of values in the registry like so:

> HKLM\SOFTWARE\Microsoft\Windows
> NT\CurrentVersion\WinLogon\DefaultDomainName = (get the current value
> for %computername% and use that value here)

> I would have preferred to do this with a reg_expand_sz entry in the
> first place, but it seems the novell client will not take the
> variable. So as it stands now (as a reg_sz entry,)when I distribute my
> ghost to my lab machines, renaming the box breaks the autologon...I
> guess enabling autologon makes the DefaultDomainName stay the same
> even when you change the machine name by normal methods.

> here is what I have tried, I am sure it is way off though (cause it
> didn't work)

> REGEDIT4

> [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]
> "test"=echo %computername%

> I get nothing by merging the above (or any other combination of "("
> "<" or "[" I have tried). I know the basic script works, because I can
> do a "test"="testdata" and show up in the right place correctly
> displaying the value testdata. I have tried many different variations
> using echo and set, but I am not a code-writer and cannot find
> examples of doing anything like this anywhere else.

> anyone out there know how to do this by any chance?

> thanks in advance for any help.

 
 
 

using environ. variable data to create a new value in a .reg file

Post by k » Tue, 03 Jun 2003 11:35:57


Thanks for the replies guys!

I may have included too many details...either that or I misunderstood
the first reply (cause it looks like you stated the same thing I
did?), or he understood it better than I did, and that is exactly what
I asked for...

All I need is a simple script (say, a .reg file that could be merged,
or a script that could be executed with reg.exe) that does this:

1) asks what is the current name of this machine right now?
2) take answer to #1 and inserts it to a pre-defined key as the new
value..

you know, something simple like:

//
REGEDIT4

*get current name of machine, place that name below*

[HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]
"test"=*name of machine/answer to above statement*
//

or just a simple command that you could place after "test"= that says
"get current name of this machine, place that name here"

that's all I need to do.

Again, thanks in advance for the help.


> Mark's suggestion looks good.

> I wrote a program to do this a while back.  You can download it from
> www.willowhayes.co.uk/download/regvars.exe

> -----
> Regvars.exe is a utility for scanning registry files (.reg) and replacing
> any instances of environment variables with their expanded versions. For
> example, if you run a reg file containing %programfiles% through the
> program, it will replace all instances of %programfiles% with, for example,
> "c:\program files".

> Regvars.exe also has an added "virtual" environment variable called %cd%,
> which evaluates to the first CD-ROM drive in the system

> The syntax is "regvars.exe input.reg output.reg". There is no error checking
> for the command line parameters and it's pretty rough and ready, but does
> the job.

> NB. Regvars.exe current doesn't accept unicode files. The default for a .reg
> file is unicode. To overcome this, when saving the input file from regedit,
> be sure to select the "95/NT regedit4" option from the save dialogue box.

> ---------------

> You would include the %computername% in your source registry file and run
> the regvars.exe program on the destination machine to create a new reg file
> with the environment variables expanded.  You can then use "regedit /s" on
> the new file to import the registry entries.

> Hope this helps

> Oli



> > I need to do the following in either reg.exe or a .reg file...

> > (This is for an autologon to local machine without an NT domain,
> > manual logon to Novell BTW.)

> > I need to use the %computername% environmental variable to make a
> > change to a couple of values in the registry like so:

> > HKLM\SOFTWARE\Microsoft\Windows
> > NT\CurrentVersion\WinLogon\DefaultDomainName = (get the current value
> > for %computername% and use that value here)

> > I would have preferred to do this with a reg_expand_sz entry in the
> > first place, but it seems the novell client will not take the
> > variable. So as it stands now (as a reg_sz entry,)when I distribute my
> > ghost to my lab machines, renaming the box breaks the autologon...I
> > guess enabling autologon makes the DefaultDomainName stay the same
> > even when you change the machine name by normal methods.

> > here is what I have tried, I am sure it is way off though (cause it
> > didn't work)

> > REGEDIT4

> > [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]
> > "test"=echo %computername%

> > I get nothing by merging the above (or any other combination of "("
> > "<" or "[" I have tried). I know the basic script works, because I can
> > do a "test"="testdata" and show up in the right place correctly
> > displaying the value testdata. I have tried many different variations
> > using echo and set, but I am not a code-writer and cannot find
> > examples of doing anything like this anywhere else.

> > anyone out there know how to do this by any chance?

> > thanks in advance for any help.

 
 
 

using environ. variable data to create a new value in a .reg file

Post by k » Tue, 03 Jun 2003 21:24:39


Ok, never mind the last post, I just made it to work and tried out
Mark's suggestion...thank you very much! Took out the ..., put in the
real reg path, and it worked like a charm!

thanks again!

 
 
 

using environ. variable data to create a new value in a .reg file

Post by Oli Restoric » Wed, 04 Jun 2003 02:55:23


Glad you got it working and thanks for the feedback.

Mark's method does look to be the simplest and did appear totally correct to
me.

Regards

Oli


Quote:> Ok, never mind the last post, I just made it to work and tried out
> Mark's suggestion...thank you very much! Took out the ..., put in the
> real reg path, and it worked like a charm!

> thanks again!

 
 
 

using environ. variable data to create a new value in a .reg file

Post by Mark » Wed, 04 Jun 2003 05:49:16



Quote:> Ok, never mind the last post, I just made it to work and tried out
> Mark's suggestion...thank you very much! Took out the ..., put in the
> real reg path, and it worked like a charm!

LOL.  Glad it work "in practice" from a "generic" representation.