Jump to content

question: Remove parts of values in registry, by cmd or batch file app


Recommended Posts

I've googled this to death, but didnt find anything that could help me. =(

I need a way to remove any of this data from this screenshot, f.ex browser service there.

The solution is going to be run from guirunonce during windows install, or pre login, but prefer to do it before, for various technical/optimal reasons.

edit: I also need a way to take complete permission of registry without actually opening regedit and manually setting permissions from there.

edit2: Look at picture, i need a way to remove any one of the lines marked in blue (example).

Imagine that you remove one of them at the time. That is what i need to be able to do.

If i find a way to do this, i can create a truly and complete automated process for "nliting" windows host system.

Therefore it would enable me to not actually need to use nlite for removing anything at all.

So needless to say then, the benefits of this would be huge, from my perspective.

post-91607-1219664173_thumb.png

Edited by TranceEnergy
Link to comment
Share on other sites


Copy the key if required for safety, 'REG COPY'

Delete the key if you dont need it's data, 'REG DELETE'

Use 'REG ADD' and add the data you wish to have in your key.

Example

@Echo off&Setlocal
::Main registry key to modify - remove Wow6432\ for WinXP
Set K_="HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\SvcHost"
::Registry keys value - you'll use netsvcs in your actual version
Set V_="testvalue"
::Type of value data to be added
Set T_=REG_MULTI_SZ
::Data to add - Use Backslash followed by Zero as a separator for multi_sz value data
Set D_="FirstDataValue\0NextDataValue\0AnotherDataValue\0LastDataValue"
::Your Reg command - remember to use the /f switch if required
Reg add %K_% /v %V_% /t %T_% /d %D_%>Nul

Link to comment
Share on other sites

Deleting ENTIRE values and copying ENTIRE values are not a problem. Unless i didnt understand something?

Example of what i want to do (i copied and pasted the first best thing i saw, no relevance whatsoever otherwise):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\drivers.desc]

"wdmaud.drv"="ASUS Xonar D2X Audio Device"

Let's say that i want "ASUS Xonar D2X Audio Device" to instead be "ASUS Xonar D2X Device"

Just for kicks.

The problem lies in that i need to be able to just specify in someway that the word "Audio" is removed.

I also need to be able to delete ^P, i mean New line, same as if i was to edit that and hit enter and come to a new line.

Look at the screenshot, see that Browser is there on a line of its own.

I need to be able to specify that i want to delete Browser and the line it sits on, so there is no empty space/similar to the rest of the value, as you see in screenshot.

edit : new screenshot: Imagine that line marked/selected with blue that it was never there, that is what i need to accomplish!

post-91607-1219684440_thumb.png

Edited by TranceEnergy
Link to comment
Share on other sites

Read what I've wrote and also run the example file and take a look in the key!

You know what it is you don't want to have in that key, so it's a simple case of recreating the multiple values you need and adding the data using 'REG ADD'. There is no need or requirement for you to attempt to search/replace/edit the existing key!

Link to comment
Share on other sites

--- HKLM\SomeKey

----- SomeValue

--------- Data1

--------- Data2

--------- Data3

--------- Data4

If we then want to delete 'Data4':

@reg add HKLM\SomeKey /v SomeValue /t reg_multi_sz /d "Data1\0Data2\0Data3" /f >nul

Btw, there's also a Win2k resource-kit tool named Regfind.exe, which features support for doing search and replace operations on the registry...

http://www.petri.co.il/download_free_reskit_tools.htm

Edited by Martin H
Link to comment
Share on other sites

--- HKLM\SomeKey

----- SomeValue

--------- Data1

--------- Data2

--------- Data3

--------- Data4

If we then want to delete 'Data4':

@reg add HKLM\SomeKey /v SomeValue /t reg_multi_sz /d "Data1\0Data2\0Data3" /f >nul

Btw, there's also a Win2k resource-kit tool named Regfind.exe, which features support for doing search and replace operations on the registry...

http://www.petri.co.il/download_free_reskit_tools.htm

Thanks martin i will look at that reskit tools set.

However your reg command wouldnt help me, because i can't rely on that i know what the contents of the registry already is.

In order for the command to work 100% reliably i would NEED to NOT rely on that i know the contents of it.

I hope that makes sense.

I'm making batches that will do practically what Nlite does, only i can revert every change there is, at least that's the plan.

However i also want to be able to do both, either completely remove (nlite mode), or backup/restorable mode.

So for now i will just have to use reg copy command i guess, and work on that scheme.

Link to comment
Share on other sites

i can't rely on that i know what the contents of the registry already is.

In order for the command to work 100% reliably i would NEED to NOT rely on that i know the contents of it.

I'm sorry but I think it's you who need to indulge me!

I cannot at all understand your thinking on this matter, how do you expect this to work?

The most suitable method is to change the settings to what you want.

Lets say for instance that a multi_reg_sz key by default contains Item1, Item2, Item3, Item4, Item5, Item6, Item7 and Item8; you or your user wants to have Item1, Item4, Item5, Item7, Item8 and a new item, Item11.

In order for batch file to find out which items are required for a particular installation it needs to be told; either before or during install. If it's before, then you already know what you want and can therefore create the keys yourself and import/overwrite them as part of the installation. If you need to find out interactively during install, then you'd list the defaults and ask the user to choose from/add to that list. The results of this list would be compiled into the key you require and registry imported/overwritten.

It would be fool-hardy to suggest that you query a key, parse it, list the data, ask for choices, compare the lists, then say, "for each data value in selected key, if not in chosen list remove it from the key, then if choice is not in parsed list add it inline".

Link to comment
Share on other sites

Expecting it to work or not, does not matter. I need a way to do it. It's that simple. I can't know if the windows source has already been modified, therefore i cannot know for sure what keys are already there.

I do however think that if i could just copy the contents of the key, then say add the variable to be removed or added to that reg copy, it would work.If thats possible.Which im sure it is.

I just got out of bed and haven't had coffee yet. =)

Link to comment
Share on other sites

I can't know if the windows source has already been modified, therefore i cannot know for sure what keys are already there.
Yes you can, REG LOAD the hive(s) and REG QUERY the keys in exactly the same manner as on a live system. If key exists then delete it and write a new key, if key doesn't exist just write the key.

Due to your continued disagreement with me on this subject, it appears that we're both seeing things in different ways. Why don't you just give a complete real world example of exactly what it is you need to do, this is after all a batch file, not a secret commercial piece of software you're trying to produce.

Link to comment
Share on other sites

Lol i am not trying to hide anything, and i have already said why i want to be able to do what i have said.

Not that i should have to explain myself WHY i want to be able to do something, i've always kind of disagreed with that kind of thought.

It does not matter, if somebody wants to be able to do something just try to help. Generally speaking on forum issues arising.

I have currently written some batch files, that may or may not be used in conjunction with nlite and or such programs,

that will take windows components, unregister them and move them out of their location.

So f.ex i move a file out of windir\system32\ and place it on systemroot\bakup\system32\.

That part i got down without problems.

However, if i want, and i do, to be able to sort of say "accept changes" to system, then i would need ways to properly delete things.

I have already given several examples of what i want to do, i don't know how much better i would be able to explain by writing any more examples.

dont forget: The specific reason behind this thread was that i need a way to be able to delete parts of a value and not its entire value.

For the time being i will just continue to write batches that will move components the safe way, and focus on deletion afterwards.

I think the tool Martin H mentioned might be just the thing, i've downloaded all the 2003 resource kit, which i more or less assume could work, or have links to their 2003/xp-64bit parts.

Ability to search for a specific data within value in registry and modify/copy/delete it will do whatever i need to i think, so sounds good.

Link to comment
Share on other sites

Try giving us a real world example from your project, showing the full key(s), data and value(s) to be changed and the question/options you'd ask instead of

first best thing i saw, no relevance whatsoever
When you have done so, either myself or some other interested member, may be able to help with a resonable solution.

We are not mind readers, only you know exactly what it is you want, if you do not tell us this information in its entirety then how can we be expected to help you achieve your goal?

Link to comment
Share on other sites

  • 2 weeks later...
Try giving us a real world example from your project, showing the full key(s), data and value(s) to be changed and the question/options you'd ask instead of
first best thing i saw, no relevance whatsoever
When you have done so, either myself or some other interested member, may be able to help with a resonable solution.

We are not mind readers, only you know exactly what it is you want, if you do not tell us this information in its entirety then how can we be expected to help you achieve your goal?

in post #5 i think it was pretty clear of an example of what i wanted to do?

I tried that mind readers comment, got my head bitten off =(

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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