Visual Fox pro RUN | ! command runs any external program using cmd.exe. But it shows Black window running in background of called Program by RUN command and it remains open till called program is active.
As alternative of RUN wscript.shell script can be run but it has dependencies for windows scripting to be installed & enabled to run Client/server system.
[Recomended Solution]
I prefer to use myself & recommend Windows API Call shellExecute(), which works as alternative to above both methods. It does not shows any Black window in your developed application to make it UGLY for user dis-appointment.
Why not Shellexec() Alone to use.?
I used windows Sleep() function & CMD with Shellexec() in my runfile() function.
Trick implement in runfile() function is that Shellexec() calls 'CMD' to run the passed parameter in string variable. Shellexec() executes 'CMD' as silent application, Finally we get Rid of UGLY Black windows to display on screen.
CMD can run all windows application as well as DOS internal commands are supported .
Hence we can run all DOS supported commands in runfile() which can not be executed alone in Shellexec().
see bellow image running Notepad.exe with no-background Black window.
Bellow is my function Code which is replacement of all you required to hide Black window.
Hi Folks!
This is all what i did, now its upon your will to adopt the way to complete your task!
Regards!
Zia Mughal
As alternative of RUN wscript.shell script can be run but it has dependencies for windows scripting to be installed & enabled to run Client/server system.
[Recomended Solution]
I prefer to use myself & recommend Windows API Call shellExecute(), which works as alternative to above both methods. It does not shows any Black window in your developed application to make it UGLY for user dis-appointment.
Why not Shellexec() Alone to use.?
I used windows Sleep() function & CMD with Shellexec() in my runfile() function.
Trick implement in runfile() function is that Shellexec() calls 'CMD' to run the passed parameter in string variable. Shellexec() executes 'CMD' as silent application, Finally we get Rid of UGLY Black windows to display on screen.
CMD can run all windows application as well as DOS internal commands are supported .
Hence we can run all DOS supported commands in runfile() which can not be executed alone in Shellexec().
see bellow image running Notepad.exe with no-background Black window.
Bellow is my function Code which is replacement of all you required to hide Black window.
********************************************* * Author : witten by Zia Mughal * CopyRight : Pcland Software Inc. Pakistan * http://www.pcland.com.pk **********************************=runfile("notepad.exe", "untitled.txt" )
**********************
FUNCTION runfile PARAMETERS rfile, lcmdpara ********************************** DECLARE INTEGER ShellExecute IN shell32.dll ; INTEGER hndWin, ; STRING cAction, ; STRING cFileName, ; STRING cParams, ; STRING cDir, ; INTEGER nShowWin local lcCMD, lcParas
DECLARE Sleep IN Win32API INTEGER lcCmd = rfile && command to Execute
lcParas = lcmdpara && Extra parameter to pass your command
* --- Execute the command.
**** shellExecute last parameter 0 will hide DOS window *** If you want to show DOS window change it to value 1 ShellExecute(0,'open','cmd', '/C'+lcCmd+' '+lcParas, '',0)
sleep(2000) && delay time to come back *** sleep value can be reduced according to your need CLEAR DLLS ShellExecute * --- Return to caller. RETURN ENDFUNC***********************************
Hi Folks!
This is all what i did, now its upon your will to adopt the way to complete your task!
Regards!
Zia Mughal