Logon script fails on to change Preferred DNS settings on Windows 7


  • Recently we did an AD migration from Windows 2003 server to Windows Server 2008 R2 for one of our client. All client machines in the domain are provided with static ip settings and all are pointing to old Windows 2003 servers. we have a script to change the preferred dns server to the new windows 2008 machine:

    @echo off

    netsh interface ip set dnsserver "Local Area Connection" Static

    netsh interface ip add dnsserver "Local Area Connection"

    Now, we would like to know how to run this script on client machines running Windows 7 OS. Would it be as a Logon Script or a Start up script. Also how to execute this script on machines where users have no admin rights.

    I have tried creating a GPO for the particular OU. But dont see the script to execute either as logon or startup script. 

    All help would be appreciated. 

    Sunday, June 03, 2012 7:59 PM


All replies

  • If you run it as a startup script it will run as the local system account. You need to make sure and give "Domain Computers" access to the share that is storing the script. You could also try this.

    Monday, June 04, 2012 12:14 AM
  • we are now planning to use PSExec.exe tool. Can anyone let me know how to use the psexec tool with a text file containing the IP list. can you give me an example for it
    • Edited by Phoenix_007 Wednesday, June 06, 2012 4:39 AM
    Wednesday, June 06, 2012 4:39 AM
  • Hi,

    Thanks for posting here.

    If we have save these scripts into a bat file then we can execute it on multiple remote hosts by psExec.exe at one time, we can get the examples form the link below:

    Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,... ] cmd [arguments]

    PsExec v1.98

    please also make sure all interface on each destination host has same name .


    Tiger Li

    Tiger Li

    TechNet Community Support

    Wednesday, June 06, 2012 6:14 AM
  • Thanks Tiger,

    But the link does not give any example of using @file. So wanted to know how to use a text file which has list of ips. As per the examples, i can provide computer1, computer2 & so on.. but i would like to know how to define the path of text file. 

    Option 1: Define the complete UNC path of the text file containing the ips?

    Option 2: Save the text file in the same folder as PSTools?

    If someone has tried using the @file syntax????

    Wednesday, June 06, 2012 7:33 AM
  • Hi Phoenix 007,

    Thanks for update.

    If we have computer names and IP addresses of a bunch of destination hosts then we can specify in “computer” parameter like “[\\computer[,computer2[,...]” and yes, we can have a file that contains these information and put psexec to execute command on these hosts one by one , please take look the example in the thread below:

    psexec @file

    Meanwhile, it is suggested post to Sysinternals Utilities official forum if we have more questions on this utility :


    Tiger Li

    Tiger Li

    TechNet Community Support

    Thursday, June 07, 2012 4:45 AM
  • Thanks Tiger. The link answered my query :-)
    Saturday, June 09, 2012 8:38 PM