Solved NETSH commands not working from batch file

Muyfa

New Member
Messages
68
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 Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
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 Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
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 Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
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 Computer

System One

  • OS
    Windows 8 Pro
    Computer type
    PC/Desktop
    Memory
    6 GB
    Screen Resolution
    1280 x 1024
    Hard Drives
    12 TB in 6 disks
    PSU
    TX650
    Keyboard
    G15
    Mouse
    Intellimouse 3.0
    Internet Speed
    100 Mbits
    Browser
    Chrome
    Antivirus
    Trend Micro
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 Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
Ok, it's because the syntax is wrong, use this:

Code:
netsh address name="Network Name" source=DHCP
 

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
The following command was not found: address name="Network Name" source=DHCP

With my correct network name of course.

Not working.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
That's the syntax for address name though - It might have to be the name of your router
 

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
But I don't want to change anything in the router, only in Windows.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
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 Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
I already did that. My original command works perfect if I manually enter it in the prompt, but as soon as I take that exact command and paste into a batch file, it all goes south.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
And you are running it elevated? I guess something happens when it's in a batch file. Try putting it into a command script or a macro
 

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
I tried command script too. No difference.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
The first link is "content not found" and the second one I've read a couple of times already. It does not seem to help.

Oh well. I guess we'll never know why this won't work.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
Your final link seem very helpful. I've tried some of the suggestions, but still it won't work. I guess my basic NETSH skills are very limited...
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
Well you and me both, I just don't get it. Mainly, it says that "set name" can't set any name that's not already set. Which defeats the purpose of using the command. :/ :\
 

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
Hmm. Funny thing - I found a program that does what I want. I can even export the commands it uses to a command file, but even doing it that way, a command or batch does simply not work.
 

My Computer

System One

  • OS
    Windows 8
    System Manufacturer/Model
    -
    CPU
    i5 3570K
    Motherboard
    Asus P8Z77-M
    Memory
    Corsair 16GB
    Graphics Card(s)
    EVGA GTX670 FTW
Which program? So, it works, but when exporting the commands it uses, they DON'T work? :(
 

My Computer

System One

  • OS
    Windows 8 Pro with Media Center/Windows 7
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Asus M2N-MX SE Plus § DualCore AMD Athlon 64 X2, 2300 MHz (11.5 x 200) 4400+ § Corsair Value Select
    CPU
    AMD 4400+/4200+
    Motherboard
    Asus M2N-MX SE Plus/Asus A8M2N-LA (NodusM)
    Memory
    2 GB/3GB
    Graphics Card(s)
    GeForce 8400 GS/GeForce 210
    Sound Card
    nVIDIA GT218 - High Definition Audio Controller
    Monitor(s) Displays
    Hitachi 40" LCD HDTV
    Screen Resolution
    "1842 x 1036"
    Hard Drives
    WDC WD50 00AAKS-007AA SCSI Disk Device
    ST1000DL 002-9TT153 SCSI Disk Device
    WDC WD3200AAJB-00J3A0 ATA Device
    WDC WD32 WD-WCAPZ2942630 USB Device
    WD My Book 1140 USB Device
    PSU
    Works 550w
    Case
    MSI "M-Box"
    Cooling
    Water Cooled
    Keyboard
    Dell Keyboard
    Mouse
    Microsoft Intellimouse
    Internet Speed
    Cable Medium Speed
    Browser
    Chrome/IE 10
    Antivirus
    Eset NOD32 6.x/Win Defend
    Other Info
    Recently lost my Windows 8 on my main PC, had to go back to Windows 7.
Back
Top