Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [Batch] Ping Script?  (Read 16130 times)

0 Members and 1 Guest are viewing this topic.

CaTaLinU

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    Re: [Batch] Ping Script?
    « Reply #15 on: May 09, 2012, 12:38:09 PM »
    now i am waiting ~ 5 sec ....

    Salmon Trout

    • Guest
    Re: [Batch] Ping Script?
    « Reply #16 on: May 09, 2012, 01:08:48 PM »
    Regarding the issue of giving a script the same name as a Windows command, the situation is this: at the prompt, or in a script, when the command interpreter cmd.exe finds something which might be a request to execute something, (without an extension) in this situation it was 'ping', it first looks in the current folder for an executable file with that base name. If there are more than one matching file, it chooses the first extension listed in the PATHEXT system variable. The default value of this is .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH. If it does not find anything in the current folder, cmd.exe then does the same in turn for each folder listed in the PATH system variable, in the order that they are listed. The default value of PATH for XP is C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem. So if you insist on calling a script ping.bat, and having the Windows ping command in it, then use the full name of the Windows command, that is ping.exe, within the script. For absolute avoidance of name collisions, avoid the search of the PATH folders by using the full command path as well, e.g. C:\Windows\system32\ping.exe.

    Note that the above applies to commands which are separate programs. If you insisted on having a script called dir.bat, and you typed DIR at the prompt, the sript wouldn't run, because DIR is an internal Windows command, not a separate program like ping. You'd have to type dir.bat.