Why do I get error "The filename, directory name, or volume label syntax is incorrect" using netsh set route?

2

1

On a windows7 machine I was trying to set the standard gateway following this example:

netsh.exe interface ipv4 set route 0.0.0.0/32 "Internet" 172.16.5.1

which returned the following error:

The filename, directory name, or volume label syntax is incorrect

Why is that the case, and how can I fix set the standard gateway for my connections?

Alex

Posted 2014-07-22T12:05:26.353

Reputation: 337

What are you trying to accomplish by 0.0.0.0/32? This won’t ever match anything, except 0.0.0.0. 0.0.0.0/8 is a reserved net. – Daniel B – 2014-07-22T12:31:54.277

@Daniel: So the example in the link given does not make any sense? – Alex – 2014-07-23T05:29:26.177

1Exactly, it’s simply wrong. You can easily check this yourself: run netsh interface ipv4 show route and you’ll see the default gateway has 0.0.0.0/0 as its target network. – Daniel B – 2014-07-23T05:54:08.700

Answers

3

There's some kind of an "underlying name" to the interface, set up on its 1st creation, or when it's manually changed. You can get it using:

netsh interface ipv4 show config

It might be different from what you see in the GUI window or from running netsh interface show interface

Try using that interface name instead - this worked for me on windows 7.

mork

Posted 2014-07-22T12:05:26.353

Reputation: 131

3

You need to use your real interface's name instead of "Internet". You can list them with netsh interface show interface.

piernov

Posted 2014-07-22T12:05:26.353

Reputation: 1 796

1

I just had a similar same issue. The problem was the " character. I copied the netsh from a word document I got from our software vendor and pasted that directly into the CMD and changed the needed parts which failed with the error mentioned here. However when I copied the string at first to notepad and replaced one from the " I discovered that they are different, so I replaced both / re-typed both and the issue is solved now.

BastianW

Posted 2014-07-22T12:05:26.353

Reputation: 479

0

Apparently on Windows 7, you need to use a different syntax to execute the command in the correct context. Preface the context specifiers interface ipv4 with a -c parameter and quote the entire context specifier. For example, to set the adapter to DHCP:

netsh -c "interface ipv4" set address name="Local Area Connection" source=dhcp

Jeff

Posted 2014-07-22T12:05:26.353

Reputation: 1