• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ooohhh bat file help, or something similar, to query/change xp registry keys

So Im pretty much a scripting/programming know-nothing. I've done some really, really simplistic bat files before, and I need something slightly less simplistic for a task at work, but Im not sure how I can make it work (or if it's doable in a bat file or what not)

The task: we have several models of workstations running windows xp pro and I want to be able to check the speed/duplex settings remotely. Windows doesnt really support that, however, the drivers we use set a value in a registry key to determine the speed/duplex config of the nic.

for example, 3 models use a broadcom nic/driver that sets the speed via the following key:
Code:
HKEY_LOCAL_MACHINE\system\currentcontrolset\control\class\{4d36e972-e325-11ce-bfc1-08002be10318}\0001\RequestedMediaType REG_SZ	0

I can drop scripts, reg keys, whatever on machines and remotely access them via a cli console (thank you, dameware). Id like a script that can check for one of 4 keys (each driver puts the key in a different place), report the value, and if the value isnt 0 (which is auto negotiate) set it to zero, or just run a trimmed-down .reg key that will replace the value with what I want.

I can check for a key with this command:
Code:
reg query hklm\system\currentcontrolset\control\class\{4d36e972-e325-11ce-bfc1-08002be10318}\0001\ /v RequestedMediaType

It returns:
Code:
! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\system\currentcontrolset\control\class\{4d36e972-e325-11ce-bfc1-08002be10318}\0001\
    RequestedMediaType	REG_SZ	0

If reg_sz is set to anything other than zero I want it to change it to zero, or run a reg key I have which does the same thing. Is there a way to do this with a bat file? I know thats a pretty simplistic way of wanting to handle it, but Im not going to get someone here to distribute a registry change like this via group policy or our app distribution system. I'm an intern tasked with some monkey work...and I really hate doing things that way.

Worst case I can run the query on each machine and see the output, then run the reg key manually, but if I could have it automated that would be sweet. Im looking at having to do this to hundreds of machines so Id like to save as much time as possible, but this is something that really isnt my area :-/

Otherwise I have to wait to get the machines idle where I can remote them and check/change the settings manually, which is tedious and time-consuming. This may not even be a great way to do this, but the tools and options are there so it seemed like it was worth looking into.

any help, pointers, useful documentation etc appreciated.

Thanks
/if i knew what i was doing this would probably be some simple if/then/else kind of thing. but...i dont really know what im doing
 
If you need this to be 0 on every machine, can't you just assign it 0 regardless of what it currently is? It would save needing to run a check on it first.

IIRC if the key doesn't exist it will create it for you also, I'm not sure if that is a problem or not.
 
If you need this to be 0 on every machine, can't you just assign it 0 regardless of what it currently is? It would save needing to run a check on it first.

IIRC if the key doesn't exist it will create it for you also, I'm not sure if that is a problem or not.

Good point, is there any reason why you can't use a reg file that adds or changes every possible key? Having a reg key entry for a non-existent driver won't hurt anything.

You could also add a bat file to the startup folder for the PC so this happens when it boots, unless the driver messes with the value after startup.
 
Good point, is there any reason why you can't use a reg file that adds or changes every possible key? Having a reg key entry for a non-existent driver won't hurt anything.

You could also add a bat file to the startup folder for the PC so this happens when it boots, unless the driver messes with the value after startup.

It works for us doing it that way. We lock down a bunch of stuff and just do it with a reg file. We also have the reverse (unlock), but it doesn't matter if I run them in the wrong order, it just sets the value regardless of what it originally was.

If you you really need to get fancy with conditions, you can try the powershell like mentioned above, or write a wscript or vbscript. I have the basic script syntax for modifying registry keys at work, if you want me to post them, I can.
 
Only have a few minutes but you could do something like this:

Code:
reg query key /v keyname | find /i "reg sz  0"
IF NOT %ERRORLEVEL%==0 call :run_reg_key

errorlevel should be 0 if a match was found and 1 if no match was found
 
thanks for the responses. it was a few extra days before i was finally given access to get this work done

yes, i can just set the value to 0 for a given model, im not sure how adding the keys would affect the drivers, so ill test that. most of them are broadcom drivers, and have the same directory structure in the registry, but the value in a different place (ie hklm > controlset001 > current > blah > 12345-2 > [001,007,008] > string/value

ill test out how having those extra pieces in an existing file works. maybe it wont cause any issues but it wont surprise me if it does

the problem also doesnt appear to be quite as bad as I was told it could be. I had been made to expect several hundred machines but itll probably be well under 300, which is a relief 🙂

i know less than zero about powershell. if its not included in xp, or xp sp3, then its not on our systems and i cant use it. if it is...then i still dont know anything about it. admittedly, knowing some kind of scripting would help me a lot, but ive always been godawful and doing even the most basic of programming/scripting

thanks for the replies 🙂
 
Back
Top