P. Jerome
P. Jerome

Reputation: 393

netsh - The syntax of the file, directory, or volume name is incorrect

I am actually trying to make a script to change my network whenever I want to. But the netsh command result in an error. FYI, my OS is set to French Language.

Here is my code :

SET NomConnexion=ReseauLocal
SET IP=192.168.1.188
SET Masque=255.255.255.0
SET Passerelle=192.168.1.254

netsh interface IP set address "%NomConnexion%" static %IP% %Masque% %Passerelle% 1

SET DNS=8.8.8.8
SET DNS2=8.8.4.4
netsh interface IP set DNS "%NomConnexion%" static %DNS% primary
netsh interface ip add dns "%NomConnexion%" %DNS2% 2

Resulting with this error (x3) : "The filename, directory name, or volume label syntax is incorrect".

I also tried without quotes, but it didn't work also. I tried to save my .bat files with notepad++ & notepad.exe, with different encoding methods, but nothing changed.

Any idea ?

Upvotes: 0

Views: 1987

Answers (1)

P. Jerome
P. Jerome

Reputation: 393

I found out the solution using @Gerhard Barnard comment.

I used this :

netsh interface show interface

To display all my interfaces names, and then take the good one and apply it to NomConnexion. Everything works now. Thanx !

Upvotes: 1

Related Questions