Jump to content

Recommended Posts

Posted (edited)

Hi all,

I'm having a very odd issue with a batch file, simply designed to ping a machine and report it up or down.

The script is as follows;

ping -n 1 192.168.0.1 | find "TTL=" >nul
if errorlevel 1 (
echo Host down.
) else (
echo Host up.
)

 

The weirdness comes from the fact that, if I run the above as Admin, it works fine. However, if I just double click the batch file as a standard user, it returns;

^C^C^C^C^C^C^C^C^C^C^C^Cthe process tried to write to a nonexistent pipe^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C

etc...

The CTRL+C (^C) prompts come up over and over for a while, until CMD crashes out. I'm not pressing CTRL+C.

I have no idea what's going on!

Edited by haze1434
amended coding syntax
Posted
13 hours ago, kdodge said:

I just tried your BAT file on a freshly installed Win7, and it runs just fine as a normal user. I think something is gummed up in your system, try running just 'ping -n 1 192.168.0.1 | find "TTL=" ' without the null redirect at the end, and not in a BAT file, see what happens

I get no return, but then that's expected. It doesn't crash CMD though. None of the odd behaviour above.

What's confusing me is that it runs as Admin, same file from the same location, but not as my standard user account. Weird. It's on my standard user account's Desktop as well, so it should have no issues running it.

Posted

What version of windows are you running?

Posted (edited)
On 12/29/2016 at 4:28 AM, haze1434 said:

7

Create a shortcut to the bat script. Right click the shourtcut, and then click advanced, and check "Run as administrator" and try again. Let me know what happens. 

 

http://imgur.com/a/VhYNX

Edited by digip

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...