Windows 8 and 8.1 Forums


NETSH commands not working from batch file

  1. #1


    Posts : 68
    Windows 8

    NETSH commands not working from batch file


    I'm trying to create a NETSH batch file that sets my TCP/IP settings to DHCP.

    The line I want to use is:

    netsh interface ipv4 set address name="My Custom Named Network" dhcp

    If I run the global cmd prompt and paste this line, it works as intended. However, if I create a batch file with the same line, I get "The filename, directory name, or volume label syntax is incorrect".

    Anyone, please? Any clue? This is bugging me plenty.

      My System SpecsSystem Spec

  2. #2


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    Probably needs to be an elevated command. Create a macro using Powershell, or run the BAT file as Admin.

    I just ran a show command from Netsh, it didn't seem to require Admin. Maybe post your Bat file with code tags and we can go over the syntax.
      My System SpecsSystem Spec

  3. #3


    Posts : 68
    Windows 8


    The actual batch file command I use is the one i wrote:

    netsh interface ipv4 set address name="My Custom Named Network" dhcp

    Except for the name of the network, but I am using the actual real name.

    It does not differ if I go with "run as Admin". Same error. The regular "cmd" prompt works as intended, only the batch does not. I googled this, and there seem to be very little about it.
      My System SpecsSystem Spec

  4. #4


    Posts : 467
    Windows 8 Pro


    Quote Originally Posted by Muyfa View Post
    The actual batch file command I use is the one i wrote:

    netsh interface ipv4 set address name="My Custom Named Network" dhcp

    Except for the name of the network, but I am using the actual real name.

    It does not differ if I go with "run as Admin". Same error. The regular "cmd" prompt works as intended, only the batch does not. I googled this, and there seem to be very little about it.
    I have had similar problems with other commands for other programs, in the end , I had to use the exact path name for the item I was trying to run in my batch file.
      My System SpecsSystem Spec

  5. #5


    Posts : 68
    Windows 8


    I did actually already try C:\Windows\system32\netsh.exe and C:\Windows\SysWOW64\netsh.exe in the batch file, with no difference. I figured maybe it was a PATH problem, but it does not seem like that either...
      My System SpecsSystem Spec

  6. #6


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    Ok, it's because the syntax is wrong, use this:

    Code:
    netsh address name="Network Name" source=DHCP
      My System SpecsSystem Spec

  7. #7


    Posts : 68
    Windows 8


    The following command was not found: address name="Network Name" source=DHCP

    With my correct network name of course.

    Not working.
      My System SpecsSystem Spec

  8. #8


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    That's the syntax for address name though - It might have to be the name of your router
      My System SpecsSystem Spec

  9. #9


    Posts : 68
    Windows 8


    But I don't want to change anything in the router, only in Windows.
      My System SpecsSystem Spec

  10. #10


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    Have you used that command outside of the batch file? I don't understand the use of that particular command in NETSH, I'll have to look it up.

    You are trying to rename your network from "Network 2, 3, etc" to something other than that?

    Actually your original syntax was good, but there is something wrong with the name you aer setting. Try doing it manually through a command prompt, and if it works, then copy it exact and make a BAT file from that. Run it as Admin.
      My System SpecsSystem Spec

Page 1 of 3 123 LastLast
NETSH commands not working from batch file
Related Threads
Need Batch File Help in General Support
First off, sorry if this is not posted in the right forum. I wasn't sure if it was more appropriate here or in the "Chillout Room" or elsewhere. I'm a noob when it comes to batch scripts, so I'd appreciate any help I could get. I tried doing all sorts of searches to find my answer (at least one...
netsh issue in Network & Sharing
I'm running windows 8.1. I'm using netsh hostednetwork to allow my Android to pick up wifi. after a period of time, I can no longer access the net. Everything seems to be the same windows-wise, nothing changed that I can tell, so I'm not sure if this is a windows or Android issue. Droid still shows...
I accidentally set the file open of .bat files to Notepad. From a link in this forum (How to Restore Default File Extension Type Associations in Windows 8 and 8.1)was able to reset the registry back I think. The bat file not longer asks for notepad but instead opens "How do you want to open this...
I need a way to play a video constantly all day, I found the following batch file which when edited for my video works perfectly in both Chrome and Firefox but does not work in Internet explorer(IE) Does any one have a solution for IE please. The Batch file is as follows:- <!DOCTYPE html> <html>...
If anyone is interested, I made a tutorial on using a batch file to run dism & sfc. https://www.eightforums.com/windows-updates-activation/40095-windows-update-wont-download-sfc-finds-corrupt-cant-fix-2.html#post336782 I hope it is useful to someone. :)
Solved Batch file question in General Support
Hi, I'm writing a small batch file, but it doesn't show everything. Can you help? @echo offsetLocal EnableDelayedExpansion pushd "C:\Users\%username%\Desktop" type nul > "%hostname% %username%" I also want to add IP-address (and maybe leave the username out).
Since Windows 8 is not creating System Restore points, apparently because I have a dual boot Windows 8 / Windows 7 setup, I'd like to schedule one every 3-4 days or so. Is there any way to run system restore from Command line or batch file or Powershell? If so then I could schedule it to run...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook