Solved

batch file ?

Posted on 2014-02-07
14
481 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 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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