Solved

batch file ?

Posted on 2014-02-07
14
482 Views
Last Modified: 2014-03-05
I have a program that will only run after you ping the host. I have no idea why but if you open it, it can't communicate with the host but if you ping the host PC it will opn and stay working till you close it. So I was thinking of a batch file that pings the host I just either put in the users startup or a scheduled task but they user complains that it shows the ping on his screen. Is ther any way of running this hidden to the user
0
Comment
Question by:Axis52401
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39843708
Call your batch from VBS:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run Chr(34) & "C:\path\to\pingserver.bat" & Chr(34), 0
Set WshShell = Nothing

Save the above as pingserver.vbs and schedule that to run at startup.

The important detail is the 0 parameter: sets intWindowStyle to 0, i.e. hidden


HTH,
Dan
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39843800
you could always run a quick ping, i.e.
ping -n 1 -w 50 hostname >NUL
which should ping only once for maximum of 50ms.
you can probably do that minmised using start "" /min ......
Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39844189
depending upon how long it lasts working too you could add a ping in as a startup script in group policy or through HKLM/microsoft/windows/current verion/run key in registry then it would ping before user logs on to pc.

what is the app btw?  If you want to know why could try capturing network trafiic when it is already pinged, and when it is not.

sounds unlikely but could be if you added ip and mac address to arp table

arp -s x.x.x.x xx-xx-xx-xx-xx-xx

Steve
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 77

Expert Comment

by:Rob Williams
ID: 39844264
I believe you are asking for a single batch file for which you can have an icon or shortcut, that pings the host and then starts the application.  Something like the following should work, substituting the correct IP (or host name) and application path in place of notepad.  Just save as something like MyApp.bat  and double click on it to run.


ping -n 2 192.168.123.123
start  C:\Windows\system32\notepad.exe
Exit

Note:  "-n 2"  pings the host twice you can adjust how many times. If you need a delay of any sort, increase.
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39844280
the user complains that it shows the ping on his screen.

I assume that means the OP had discovered batch and ping, and needs a way to make this silent...

Is there any way of running this (ping) hidden to the user?
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 39844286
The simplest way is to create a shortcut for the batch file, then under properties of the shortcut, under the "shortcut" tab, in the "Run" box select minimized.   This way you just show the command prompt window as an icon on the task bar for about 3 seconds instead of a command window.  To have it completly hidden I belive you would need to use VBS, which is not a strong suit of mine.
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 39844291
Having said that:  it sounds like we are addresing the problem symptms and not the problem.  Why do we need to ping the host?  Perhaps a DNS issue?

In another question you address a VPN, is this over a VPN connection?
Is this a domain or workgroup environment?
0
 
LVL 2

Author Comment

by:Axis52401
ID: 39876807
its local not over a VPN, I have a host file entry to account for DNS
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 39903411
I am wondering why it works after you ping the host and not before.  When you ping the host it will add an entry in the local arp table.  This will expire in time.  Just as a test and to diagnose the problem, rather than pinging try first adding a static entry in the arp table.  To do so you need the IP and MAC address of the host, then use the following format:

arp  -s  192.168.123.123   1A-1A-1A-1A-1A-1A
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39903501
Rob, I thought that could possibly be the case too http:#a39844189 but didn't get a response.

Steve
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 39903669
Sorry Steve, just reviewing open questions and missed you already suggested that.
Cheers!
--Rob
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 39906243
Thank you Jason0923.  I hope that did solve your problem but points should be awarded to dragon-it not me, or at a minimum a point split.  Please click the request attention link and ask the moderators to adjust.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39906497
Not that I'm not grateful for the points, but I don't think that's the solution Jason wanted to accept :)
Maybe try again?
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Resolve DNS query failed errors for Exchange
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question