Page 1 of 1
can you do this batch ocrrectly for me please
Posted: 07 Apr 2020 03:50
by abuchaibe3
Hello there, im really noob with cmd prompt xD i made two basic (i guess) scripts and they didn't work, it says it's incorrrect:
@echo off
netsh interface ipv4 set dnsservers "Conexión de red inalámbrica" static 8.8.8.8 primary
netsh interface ipv4 add dnsservers "Conexión de red inalámbrica" 8.8.4.4
netsh interface ipv6 set dnsservers "Conexión de red inalámbrica" static 2001:4860:4860::8888 primary
netsh interface ipv6 add dnsservers "Conexión de red inalámbrica" 2001:4860:4860::8844
ipconfig /flushdns
pause
all those command works if i write them normally by myself, xD but it won't if i write them in a notepad... i dont really know what's wrong, it says "
The filename, directory name, or volume label syntax is incorrect inside batch", maybe u could help me to write it correctly.

.
Also i made this one, super simple and again, it works if i dont save it as .bat with notepad, but if i do that the command doesn't stop repeating
ping 66.151.33.4 -t
My english isn't good, i apologize if i said something wrong, i hope you can understand me
Re: can you do this batch ocrrectly for me please
Posted: 07 Apr 2020 05:25
by jeb
Hi abuchaibe3,
first your problem with "ping 66.151.33.4 -t"
abuchaibe3 wrote: ↑07 Apr 2020 03:50
if i dont save it as .bat with notepad, but if i do that the command doesn't stop repeating
I guess, you save it as "ping.bat" ?
If yes, think about it a minute and you will find the problem.
Your first problem occurs probably from your utf-8 charcters.
It works in the console, but if you save it with notepad, it will store it UTF-8 encoded.
Try to save it with ANSI-Encoding (You could use notepad++ for this).
jeb
Re: can you do this batch ocrrectly for me please
Posted: 07 Apr 2020 16:08
by abuchaibe3
Hi jeb, i did what you said and it keeps repeating, i downloaded notepad++ and i saved it as ANSI batch, what should i do? And what should i do with the first script? xD i don't know what's wrong:(
Re: can you do this batch ocrrectly for me please
Posted: 07 Apr 2020 23:09
by jeb
Hi,
you should check, that there is no ping.bat in your working directory, else it will be infinitely repeated,
because "ping 66.151.33.4 -t" will call the batch file "ping.bat" not the ping.exe command.
Your other problem is the character encoding of "Conexión de red inalámbrica".
You got the error "The filename, directory name, or volume label syntax is incorrect inside batch" if there is no interface with the given name.
In your case the name doesn't match, because you saved the file with the wrong encoding.
With notepad++ you can choose Encoding->Convert to ANSI and then save the file
jeb
Re: can you do this batch ocrrectly for me please
Posted: 08 Apr 2020 02:48
by abuchaibe3
Thanks you a lot, u helped me to fix the ping command!!
The other script, like i said, if i write it normally in command prompt, by myself one command by one, it works, but if i put all those commands in one batch script it doesnt work, i don't know why, all those commands are well written, "Conexión de red inalámbrica" is okay, i proved it, thats my WiFi, what should i do in this case?
I tried this:
Code: Select all
@echo off
netsh
interface
ipv4
set dnsservers "Conexión de red inalámbrica" static 8.8.8.8 primary
netsh
interface
ipv4
add dnsservers "Conexión de red inalámbrica" 8.8.4.4
netsh
interface
ipv6
set dnsservers "Conexión de red inalámbrica" static 2001:4860:4860::8888 primary
netsh
interface
ipv6
add dnsservers "Conexión de red inalámbrica" 2001:4860:4860::8844
pause
but doesn't work, it get stuck here:
(i also tried to convert to ANSI)
Re: can you do this batch ocrrectly for me please
Posted: 08 Apr 2020 13:53
by ShadowThief
You had it correct the first time with
Code: Select all
netsh interface ipv4 set dnsservers "Conexión de red inalámbrica" static 8.8.8.8 primary
netsh interface ipv4 add dnsservers "Conexión de red inalámbrica" 8.8.4.4
netsh interface ipv6 set dnsservers "Conexión de red inalámbrica" static 2001:4860:4860::8888 primary
netsh interface ipv6 add dnsservers "Conexión de red inalámbrica" 2001:4860:4860::8844
You didn't specify what you mean by "it doesn't work," so I can't give a more detailed answer at this time.
Re: can you do this batch ocrrectly for me please
Posted: 08 Apr 2020 18:14
by abuchaibe3
Hi! this is what i did: i opened a notepad, put that lines, then saved it as a .bat file, but when i open it, it says "The filename, directory name, or volume label syntax is incorrect inside batch, press one key to continue . . ." (exactly that in spanish):
like i said, its all well written, in command prompt those commands work normally, but in the .bat file it doesnt, its encoded as ANSI and i tried to save it .exe, still not working
Re: can you do this batch ocrrectly for me please
Posted: 14 Apr 2020 06:00
by penpen
I guess it's a codepage issue:
Windows notepad uses the OEM codepage to save text (on my pc: CP 1252) while the command line interpreter (cmd.exe) typically uses the ANSI codepage (on my pc: CP 850).
So if your pc uses the same codepages, then the CP1252 string "Conexión de red inalámbrica" is interpreted as:
"Conexi¾n de red inalßmbrica".
You might download the "info.zip" and execute the "info.bat" contained in the zip-file to get your settings:
viewtopic.php?f=3&t=6108#p49091.
Then you could save, change and restore the codepage (untested; assumes CP 1252 to be your OEM codepage):
Code: Select all
setlocal enableExtensions disableDelayedExpansion
for /f "tokens=*" %%a in ('chcp') do for %%b in (%%a) do set "_codepage=%%~nb"
chcp 1252
netsh interface ipv4 set dnsservers "Conexión de red inalámbrica" static 8.8.8.8 primary
netsh interface ipv4 add dnsservers "Conexión de red inalámbrica" 8.8.4.4
netsh interface ipv6 set dnsservers "Conexión de red inalámbrica" static 2001:4860:4860::8888 primary
netsh interface ipv6 add dnsservers "Conexión de red inalámbrica" 2001:4860:4860::8844
chcp %_codepage%
goto :eof
penpen