Windows 10: Trying to make a batch file script to change the DNS on a workstation.

Discus and support Trying to make a batch file script to change the DNS on a workstation. in Windows 10 Software and Apps to solve the problem; I have tried just putting the command in a batch file and running that batch file as admin, but that doesn't work.I need it to run as elevated cmd.The... Discussion in 'Windows 10 Software and Apps' started by Hozzybear, Sep 20, 2023.

  1. Hozzybear Win User

    Trying to make a batch file script to change the DNS on a workstation.


    I have tried just putting the command in a batch file and running that batch file as admin, but that doesn't work.I need it to run as elevated cmd.The code I have used in an elevated cmd that works:netsh interface ipv4 add dns "Ethernet" 10.100.0.11 index=2I would like to be able to run an ipconfig /all, then select between the two netsh commands below.Then run ipconfig /all again to verify the change.netsh interface ipv4 add dns "Ethernet" 10.100.0.11 index=2netsh interface ipv4 add dns "Ethernet 2" 10.100.0.11 index=2

    :)
     
    Hozzybear, Sep 20, 2023
    #1

  2. Running PowerShell script as a batch file

    Hello Baldo,



    Thank you for writing to Microsoft Community Forums.



    I understand that you want to execute the PowerShell commands as a batch file.



    I tried executing the batch file on my machine but I was unable to execute it as the command was incomplete. However, after making some changes in the command I was able to execute the batch file.



    You can try the following command by saving it in a batch file and check if that helps.



    powershell –Command Get-AppxPackage Microsoft.3dBuilder | Remove-AppxPackage



    Also, as the query is related to running a PowerShell script using a batch file, I suggest you to post the issue on

    TechNet
    forums where we have professionals who have more knowledge about the issue.



    Hope it helps.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, Sep 20, 2023
    #2
  3. yegorsw Win User
    Run the audio troubleshooter from a batch script

    I have an automated home theatre setup - a batch script that enables my TV as a display, and changes the TV to be my primary display (so games and apps open on my TV instead of my monitor).

    The same script also changes my default audio device to be the TV.

    The problem is every time I turn off my TV, it disappears from the list of audio output devices in Windows 10, and even when I turn it back on, it does not appear in the list. However, if I RIGHT CLICK on the audio icon and select "troubleshoot sound problems"
    and immediately cancel/close the troubleshooter, the TV is automagically added to my list of output devices.

    My question is - is there any way to have this troubleshooter be launched from a batch script and instantly closed? Alternatively, is there a way to force a refresh of the audio devices through a batch script?
     
    yegorsw, Sep 20, 2023
    #3
  4. Julivgar Win User

    Trying to make a batch file script to change the DNS on a workstation.

    Netfix Batch Script- Fix internet connection

    Somebody please try my batch script Netfix and leave feedback so I can improve it. thank you!

    My goal is to make a troubleshooter to help the built in "Windows Network Diagnostics" fix internet connection problems. How can you help?

    1. Download/copy the code on notepad then save as "Netfix.bat" or "Netfix.cmd"

    2. Test the Batch script

    3. Provide feedback and/or suggestions

    Thank you!
     
    Julivgar, Sep 20, 2023
    #4
Thema:

Trying to make a batch file script to change the DNS on a workstation.

Loading...
  1. Trying to make a batch file script to change the DNS on a workstation. - Similar Threads - Trying batch file

  2. Trying to make a batch file script to change the DNS on a workstation.

    in Windows 10 Gaming
    Trying to make a batch file script to change the DNS on a workstation.: I have tried just putting the command in a batch file and running that batch file as admin, but that doesn't work.I need it to run as elevated cmd.The code I have used in an elevated cmd that works:netsh interface ipv4 add dns "Ethernet" 10.100.0.11 index=2I would like to be...
  3. Trying to make a batch file script to change the DNS on a workstation.

    in Windows 10 Network and Sharing
    Trying to make a batch file script to change the DNS on a workstation.: I have tried just putting the command in a batch file and running that batch file as admin, but that doesn't work.I need it to run as elevated cmd.The code I have used in an elevated cmd that works:netsh interface ipv4 add dns "Ethernet" 10.100.0.11 index=2I would like to be...
  4. Batch scripting

    in Windows 10 Software and Apps
    Batch scripting: Hi, here's the code that I used for 3 DISM commands to start automatically after pressing a key:Code and result:Code:@echo off echo You are going to use DISM. echo 1. To check the image. echo 2. Scan your PC's health echo 3. Restore your PC'S health. echo To continue, press...
  5. Batch scripting

    in Windows 10 Gaming
    Batch scripting: Hi, here's the code that I used for 3 DISM commands to start automatically after pressing a key:Code and result:Code:@echo off echo You are going to use DISM. echo 1. To check the image. echo 2. Scan your PC's health echo 3. Restore your PC'S health. echo To continue, press...
  6. Batch scripting

    in Windows 10 Network and Sharing
    Batch scripting: Hi, here's the code that I used for 3 DISM commands to start automatically after pressing a key:@echo off echo You are going to use DISM. echo 1. To check the image. echo 2. Scan your PC's health echo 3. Restore your PC'S health. echo To continue, press any key. echo Before...
  7. Any way to make a batch script to rename the most recent file?

    in Windows 10 Support
    Any way to make a batch script to rename the most recent file?: found scripts to locate a the most recent file, and scripts to rename files, but no combination. basically id need a script to rename, the most recent .pdf file added to "W:\Declarations", to 'decs365.pdf' any help is greatly appreciated 170467
  8. Batch Scripts / Programs.

    in Windows 10 Performance & Maintenance
    Batch Scripts / Programs.: The members and quests who use this forum know how professional, informative and helpful it is! In order to help members solve their problems/issues we often ask them to run certain programs and perform certain tasks and then upload [ post ] the results to the forum for us...
  9. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  10. Will these batch files work to change DNS servers to OpenDNS and back?

    in Windows 10 Network and Sharing
    Will these batch files work to change DNS servers to OpenDNS and back?: I found the following on a forum post from 2007. I'm apprehensive, however, to try it because I obviously don't want to cause anything to stop working properly. 1: netsh interface ip set dns "Local Area Connection" static 208.67.222.222 netsh interface ip add dns...