Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide DOS Window When Runnig DOS Commands

Tips -N- Tricks

Hide DOS Window When Runnig DOS Commands

by  craigsboyd  Posted    (Edited  )
Slighthaze = [color blue]NULL[/color]

[img http://www.sweetpotatosoftware.com/ttimages/doswindow.gif]

You may have noticed that when you run DOS commands like NETSTAT in VFP the DOS window will come up for a few moments and then go away. The trick to running DOS commands invisibly is to run the command through a PIF file. Cut-N-Paste the code below into a prg file and run it from within VFP. (PLEASE NOTE: a file
C:\MyPorts.txt will be created on your computer with the output from NETSTAT)

Code:
?winexecrun("NETSTAT -a -n > C:\MyPorts.txt") && DOS Window Hidden

FUNCTION winexecrun
PARAMETER cCommand

DECLARE INTEGER WinExec IN win32api ;
   STRING command, INTEGER param

retval = WinExec(SYS(2004) + "FOXRUN.PIF /C " + cCommand, 0)

CLEAR DLLS WinExec

RETURN retval
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top