Why gives pinging from a compiled VFP program no results but works from the developing environment?

When I try to get a compiled VFP exe-file to show the pinging results in a text file, the text file becomes blank (empty) but when I do it from the VFP programming environment it works and the text file shows the following result:

Pinging 192.168.16.11 with 32 bytes of data:
Reply from 192.168.16.11: bytes=32 time=12ms TTL=128
Reply from 192.168.16.11: bytes=32 time=13ms TTL=128
Reply from 192.168.16.11: bytes=32 time=13ms TTL=128
Reply from 192.168.16.11: bytes=32 time=13ms TTL=128

Ping statistics for 192.168.16.11:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 12ms, Maximum = 13ms, Average = 12ms


I have tried following command:
RUN "c:\windows\system32\cmd.exe, /c ping 192.168.16.11 > C:\Ping\pinglog.txt"

How do I do in order to get the the pinging result in the text file from the compiled program?
AndHofOwnerAsked:
Who is Participating?
 
pcelbaCommented:
This is possible for many reasons, e.g.
1) Your firewall blocks your exe from pinging
2) Your exe name is ping.exe
3) Executing external programs is not allowed by your OS settings

I've created a small EXE  (Myping.EXE) having one line of code in the main PRG:
RUN "c:\windows\system32\cmd.exe, /c ping 192.168.2.1 > C:\Ping\pinglog.txt"
and it works for me without problems in W7/64...
Of course, I have full access to c:\ping\ and I am administrator on the machine but the EXE does not require elevated rights.

If nothing from above hints helps then you could post your testing EXE for analysis? (Rename it to .TXT and ZIP it please.)

Update:
This command should also work
RUN ping 192.168.2.1 > C:\Ping\pinglog.txt
0
 
bbaoIT ConsultantCommented:
does the user running the app in prod environment have sufficient rights to access folder C:\PING?

please be aware that the folder is not a pre-existing folder on a Windows computer.
0
 
AndHofOwnerAuthor Commented:
I run the compiled program and the source program from the same machine and I have the administrator rights. The text file is created in both cases but when I run the compiled exe-file the text file is empty.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
bbaoIT ConsultantCommented:
> the text file is empty.

do you mean if the plain text file isn't existing under C:\PING and the data file's filename can be seen (generated) but with no content?
0
 
AndHofOwnerAuthor Commented:
Yes, when I ping in the developing environment the content in the text file C:\Ping\pinglog.txt is as I described it in the original question above. However, with the same command in a compiled exe-file the txt-file C:\Ping\pinglog.txt  is generated but with no content.
0
 
AndHofOwnerAuthor Commented:
Yes, you are right. The name of the program was ping.exe. However, I do not understand the problem with that. Could you please explain. However, I changed the name to pinghead and now it works. Thank you for your help.
0
 
pcelbaCommented:
The VFP app named PING.EXE looks into the app home folder first and the PING.EXE found in this folder has a precedence over the OS ping command which is also named PING.EXE (and stored in Windows\System32\).

The FoxPro IDE uses different default folder (VFP home folder probably) and the OS search finds the OS PING.EXE earlier than your own PING.EXE.

You could keep the name of your VFP app PING.EXE but then you must specify the full path to the PING.EXE from Windows\System32\ folder in RUN command.
0
 
AndHofOwnerAuthor Commented:
Thank you for putting time on such a simple question. I should have realized this myself after having worked with VFP programming for many years. But sometimes you can not see the forest for the trees (an old Swedish proverb freely translated). Either way, you saved a lot of time for me and I am very grateful for that.
Goodbye now and the case is closed.
0
 
pcelbaCommented:
We are saying it the same way but Ovidius wrote: Frondem in silvis non cernere
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.