How to change the DNSSuffixSearchOrder with WMI

Posted on 2006-04-27
Last Modified: 2008-01-09
I have this script that was generated by wmi code creator:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
' Obtain the definition of the class.
Set objShare = objWMIService.Get("Win32_NetworkAdapterConfiguration")

' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("SetDNSSuffixSearchOrder"). _
' Add the input parameters.
objInParam.Properties_.Item("DNSDomainSuffixSearchOrder") =  ",,"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("Win32_NetworkAdapterConfiguration", "SetDNSSuffixSearchOrder", objInParam)

' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue

The script is supposed to change the values of DNSSuffixSearchOrder to those assigned to it..  But what this script does it wipes the list and selects the 2 check boxes above... Append primary... etc.  My question is, can someone modify this script to achieve my goal of being able to change the suffixes list to what I want on any PC hostname passed on to "strComputer ="?
Question by:hplaud5035
    LVL 24

    Expert Comment

    Just out of curiosity first, is there some reason you want to script this instead of using group policy?
    LVL 24

    Expert Comment

    And this could also be done in a very simple batch file with the following commands....

    reg add hklm\system\currentcontrolset\services\tcpip\parameters /v UseDomainNameDevolution /t REG_DWORD /d 1 /f
    reg add hklm\system\currentcontrolset\services\tcpip\parameters /v SearchList /d ",," /f

    LVL 24

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article ( first and run the tool TDSSKiller ( to get rid of the infection. Once done, and if the …
    Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now