Ipconfig doesn't work inside a bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Squashman
Expert
Posts: 4106
Joined: 23 Dec 2011 13:59

Re: Ipconfig doesn't work inside a bat file

#16 Post by Squashman » 02 Apr 2019 14:46

None of the Microsoft ping programs (ping, pathping, psping) output: Enter the ping options:

If you are executing c:\windows\system32\ping.exe and the verbose output is Enter the ping options:, then someone hacked your system and replaced the executable. But I doubt this is the case.

It is more likely one of these two scenarios.
1) Another program named ping is in the path.
2) You are not showing us all the code in your batch file and think that it does affect the code you are trying to run.

jfl
Posts: 99
Joined: 26 Oct 2012 06:40
Location: Saint Hilaire du Touvet, France
Contact:

Re: Ipconfig doesn't work inside a bat file

#17 Post by jfl » 04 Apr 2019 03:00

Squashman wrote:
02 Apr 2019 14:46
None of the Microsoft ping programs (ping, pathping, psping) output: Enter the ping options:
I tried that on several of my systems, with various Windows versions, and indeed none of them contain that string. Ex:

Code: Select all

C:\JFL\Temp>strings C:\Windows\System32\ping.exe | findstr /i please

C:\JFL\Temp>strings C:\Windows\System32\ping.exe | findstr /i options

C:\JFL\Temp>
@Docfxit, Please try the above commands on your system, and tell us what you find.
(If you don't have the strings.exe program, it's available on Microsoft Sysinternals page: https://docs.microsoft.com/en-us/sysint ... ds/strings)
Squashman wrote:
02 Apr 2019 14:46
It is more likely one of these two scenarios.
There might be a third possibility:
- It's possible to define a registry key to define a program that will be run when another one is requested. I'm not sure if this applies here, but it's worth having a look.

@Docfxit, Please check if the following key is defined on your system:
HKEY_CLASSES_ROOT\Applications\ping.exe\shell\open\command

(Which reminds me that I never implemented that check in my which.exe program, and that I really should add it too!)

varianjv
Posts: 4
Joined: 02 May 2019 15:19

Re: Ipconfig doesn't work inside a bat file

#18 Post by varianjv » 02 May 2019 15:54

Did you try running them both from an elevated command prompt

Gustaaf
Posts: 2
Joined: 07 May 2019 04:04

Re: Ipconfig doesn't work inside a bat file

#19 Post by Gustaaf » 07 May 2019 08:13

I recommend to move C:\Windows;C:\Windows\System32; etc (anything to do with Windows) to the front of the path.
Always keep OS path statements upfront. Lots of installers simply append to the front of the path statement, pushing your much needed OS strings down the line.

This Active Perl run in Cygwin may be getting in your way as it is another command interpreter as well as PERL itself that is usually invoked via batch. Cygwin is Windows port for linux subsystems hosting if I recall.

PATH=C:\Programs\cygwin\bin;C:\Programs\cygwin;C:\Programs\cygwin\usr\local\bin\perl\site\bin;C:\Programs\cygwin\usr\local\bin\perl\bin;

Post Reply