![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||