Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Windows 7 Registry\Script Issue

Posted on 2011-04-27
Medium Priority
Last Modified: 2013-11-05
How can I query the registry for a key value, then use that value to create a DWORD in that key? Can I use a variable instead? Like '*'?

I'm trying to add an entry here 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\{Dynamic GUID here}'. The problem is the GUID is different on every computer.  I then want to create the DWORD 'DhcpConnForceBroadcastFlag' with a value of '1' in the key.

Can anyone help?
Question by:JUP_IT
  • 3
LVL 86

Accepted Solution

oBdA earned 1000 total points
ID: 35474129
Try the batch script below; it will scan all GUIDs and only add the value if DHCP is enabled for the adapter.
The script is currently in test mode, it will only display the "reg add" command it would normally run.
Remove the capitalized ECHO in line 14 to run it for real.
@echo off
for /f "delims=" %%a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces" ^| find /i "\{"') do call :process "%%~a"
goto :eof

set Interface=%~1
echo Processing %Interface% ...
reg query "%Interface%" /v "EnableDHCP" 2>NUL | find /i "0x1" >NUL
if errorlevel 1 (
  echo ... ignored, DHCP disabled.
) else (
  echo ... adding value ...
  ECHO reg add "%Interface%" /v "DhcpConnForceBroadcastFlag" /d "1" /f

Open in new window


Author Comment

ID: 35474790
Nice work, thanks. I just had to a /t REG_DWORD to create the correct value type.


Author Comment

ID: 35474794
add even

Author Comment

ID: 35475639
Can it be done as a VBS script instead? I'm having UAC issues running this via SCCM.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
It is a real story and is one of my scariest tech experiences. Most users think that IT experts like us know how to fix all computer problems. However, if there is a time constraint and you MUST not fail the task or you will lose your job, a simple …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question