Solved

batch file ?

Posted on 2014-02-07
14
477 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
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 34

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
 
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 34

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 34

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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now