Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Using .reg file syntax

Reply
 
Old 06-06-2007   #1 (permalink)
Marco Shaw


 
 

Using .reg file syntax

I've got a .reg file that looks like this:

------------
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
@="xxx-WEB-TRIAL"
"xxx"="xxx-yyy-zzz"
"xxx"=""
------------

Our IT had disabled all regedit tools, so I'm left with having to go in
with PowerShell.

I've not been able to interpret the above syntax to use it within
PowerShell.

Anyone have any ideas?

Marco

My System SpecsSystem Spec
Old 06-06-2007   #2 (permalink)
Marcel J. Ortiz [MSFT]


 
 

Re: Using .reg file syntax

Well... I think it goes something like this:

> [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx] <- This is the path
> @="xxx-WEB-TRIAL" <- This is
> the default value
> "xxx"="xxx-yyy-zzz" <-
> These are the other values.
> "xxx"=""


A script similar to this should be able to parse that:

foreach($line in get-content $regFile)
{
if ($line[0] -eq "[" -and $line[-1] -eq "]")
{
$path = $line.Trim('[',']');

write-host $path;
}
else
{
$valueName,$actualValue = $line.Split('=') | foreach { $_.Trim('"') }

if ($line[0] -eq '@')
{
$valueName = '(default)'
}

write-host "$valueName => $actualValue";
}
}

Of course, you'll need to modify it so that it skips the firstline and also
handles those weird cases such as when you have a value of type dword. In
the case of dword you'll get something like " dword:00000001" for the actual
value. I don't know what you get for qword or expandable string. You'll
have to experiment. Oh, and of course if you're trying to import the reg
file you'll need to change those write-hosts with new-item and
set-itemproperty.


"Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:uGV56KEqHHA.3948@TK2MSFTNGP05.phx.gbl...
> I've got a .reg file that looks like this:
>
> ------------
> REGEDIT4
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
> @="xxx-WEB-TRIAL"
> "xxx"="xxx-yyy-zzz"
> "xxx"=""
> ------------
>
> Our IT had disabled all regedit tools, so I'm left with having to go in
> with PowerShell.
>
> I've not been able to interpret the above syntax to use it within
> PowerShell.
>
> Anyone have any ideas?
>
> Marco


My System SpecsSystem Spec
Old 06-06-2007   #3 (permalink)
Marco Shaw


 
 

Re: Using .reg file syntax

Marco Shaw wrote:
> I've got a .reg file that looks like this:
>
> ------------
> REGEDIT4
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
> @="xxx-WEB-TRIAL"
> "xxx"="xxx-yyy-zzz"
> "xxx"=""
> ------------
>
> Our IT had disabled all regedit tools, so I'm left with having to go in
> with PowerShell.
>
> I've not been able to interpret the above syntax to use it within
> PowerShell.
>
> Anyone have any ideas?
>
> Marco


This definitely helped me out:
http://tfl09.blogspot.com/2007/05/ge...ntry-with.html
My System SpecsSystem Spec
Old 06-06-2007   #4 (permalink)
hecks@hotmail.co.uk


 
 

Re: Using .reg file syntax

On Jun 6, 2:58 pm, Marco Shaw <marco.shaw@_NO_SPAM_gmail.com> wrote:
> I've got a .reg file that looks like this:
>
> ------------
> REGEDIT4
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
> @="xxx-WEB-TRIAL"
> "xxx"="xxx-yyy-zzz"
> "xxx"=""
> ------------
>
> Our IT had disabled all regedit tools, so I'm left with having to go in
> with PowerShell.
>
> I've not been able to interpret the above syntax to use it within
> PowerShell.
>
> Anyone have any ideas?
>
> Marco


If it's just regexes you need, these seem to work (assuming $string is
the file contents):

$path = ([regex]'(?<=\[).*?(?=\])').match($tring)
$defaultvalue = ([regex]'(?<=@=\").*?(?=\")').match($string)
$valuenames = ([regex]'(?<=\")\w+(?=\"=)').matches($string)
$values = ([regex]'(?<=\")\w+(?=\"=)').matches($string)

The last two should give you arrays of matches to play with, e.g:

write "$($valuenames[1].value)" => $($values[1].value)"

-Hecks

My System SpecsSystem Spec
Old 06-06-2007   #5 (permalink)
hecks@hotmail.co.uk


 
 

Re: Using .reg file syntax

On Jun 6, 10:49 pm, h...@hotmail.co.uk wrote:
> On Jun 6, 2:58 pm, Marco Shaw <marco.shaw@_NO_SPAM_gmail.com> wrote:
>
>
>
> > I've got a .reg file that looks like this:

>
> > ------------
> > REGEDIT4

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
> > @="xxx-WEB-TRIAL"
> > "xxx"="xxx-yyy-zzz"
> > "xxx"=""
> > ------------

>
> > Our IT had disabled all regedit tools, so I'm left with having to go in
> > with PowerShell.

>
> > I've not been able to interpret the above syntax to use it within
> > PowerShell.

>
> > Anyone have any ideas?

>
> > Marco

>
> If it's just regexes you need, these seem to work (assuming $string is
> the file contents):
>
> $path = ([regex]'(?<=\[).*?(?=\])').match($tring)
> $defaultvalue = ([regex]'(?<=@=\").*?(?=\")').match($string)
> $valuenames = ([regex]'(?<=\")\w+(?=\"=)').matches($string)
> $values = ([regex]'(?<=\")\w+(?=\"=)').matches($string)
>
> The last two should give you arrays of matches to play with, e.g:
>
> write "$($valuenames[1].value)" => $($values[1].value)"
>
> -Hecks


Sorry, pasted incorrectly, the last regex should be:

$values = ([regex]'(?<!@=\")(?<==\")(\w+|-)+?(?=\")').matches($string)

-Hecks

My System SpecsSystem Spec
Old 06-06-2007   #6 (permalink)
Thomas Lee


 
 

Re: Using .reg file syntax

In message <ugt7BBGqHHA.4364@TK2MSFTNGP03.phx.gbl>, Marco Shaw
<marco.shaw@_NO_SPAM_gmail.com> writes
>Marco Shaw wrote:
>> I've got a .reg file that looks like this:
>> ------------
>> REGEDIT4
>> [HKEY_LOCAL_MACHINE\SOFTWARE\xxxx]
>> @="xxx-WEB-TRIAL"
>> "xxx"="xxx-yyy-zzz"
>> "xxx"=""
>> ------------
>> Our IT had disabled all regedit tools, so I'm left with having to go
>>in with PowerShell.
>> I've not been able to interpret the above syntax to use it within
>>PowerShell.
>> Anyone have any ideas?
>> Marco

>
>This definitely helped me out:
>http://tfl09.blogspot.com/2007/05/ge...ntry-with.html


:-)

--
Thomas Lee
doctordns@gmail.com
MVP - Admin Frameworks and Security
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Generic Interface syntax in VS 2005 using Old syntax .NET General
Batch File Syntax Help General Discussion
syntax for batch file Vista file management
"invalid STORE command syntax invalid message set syntax" Vista mail
PowerShell syntax file (ver 0.91) for TextPad PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46