Subject Re: deleting files in a remote directory
From Andy Taylor <andy.taylor@cloud15.uk>
Date Tue, 14 Aug 2018 03:48:47 -0400
Newsgroups dbase.getting-started

Rich,
Lovely. Thanks for the pointers (& well documented code!).
Now all I have to do is find the time to play with it...
Andy

> The beauty of OleAutoClient is the abilities to expand dBASE past its build
> in functionality.
> In many cases you don't even have to fool with objects. This should also
> work. (Untested)
> new
> OleAutoClient("Scripting.FileSystemObject").DeleteFile("c:\dbasewin\pictures-temp\*.jpg")
> Since we never actually created a object reference, no need to release it.
> dBASE however chokes on some command stacking like this and some parameters.
> In addtion to RunHidden() which Mervyn suggested, there are several other
> ways to run DOS commands hidden without going to 3rd party tools.
> There is ShellAndWait.prg which might be in the dUFLP and RunShellExe()
> which again uses OleAutoClient.
> Rich....
>
>    function RunShellExe(cProgram,lWaitOnReturn,nHide)
>    **************************************************
>         /* Rich, www.autotraker.com
>       ? RunShellExe("c:\windows\system32\calc.exe")
>       object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
>       strCommand
>          String value indicating the command line you want to run. You must
> include any parameters you want to pass to the executable file.
>       intWindowStyle
>          Optional. Integer value indicating the appearance of the program's
> window. Note that not all programs make use of this information.
>       bWaitOnReturn
>          Optional. Boolean value indicating whether the script should wait
> for the program to finish executing before continuing to the next statement
> in your script. If set to true, script execution halts until the program
> finishes, and Run returns any error code returned by the program. If set to
> false (the default), the Run method returns immediately after starting the
> program, automatically returning 0 (not to be interpreted as an error code).
>       intWindowStyle Description
>       0 Hides the window and activates another window.
>       1 Activates and displays a window. If the window is minimized or
> maximized, the system restores it to its original size and position. An
> application should specify this flag when displaying the window for the
> first time.
>       2 Activates the window and displays it as a minimized window.
>       3 Activates the window and displays it as a maximized window.
>       4 Displays a window in its most recent size and position. The active
> window remains active.
>       5 Activates the window and displays it in its current size and
> position.
>       6 Minimizes the specified window and activates the next top-level
> window in the Z order.
>       7 Displays the window as a minimized window. The active window remains
> active.
>       8 Displays the window in its current state. The active window remains
> active.
>       9 Activates and displays the window. If the window is minimized or
> maximized, the system restores it to its original size and position. An
> application should specify this flag when restoring a minimized window.
>       10 Sets the show-state based on the state of the program that started
> the application.
>       */
>       local x,success
>       if ARGCOUNT() < 2
>             lWaitOnReturn = true
>       endif
>       if ARGCOUNT() < 3
>             nHide = 1
>       endif
>       success = true
>       try
>           x = new OleAutoClient("WScript.Shell")
>          x.Run(cProgram,nHide,lWaitOnReturn)
>       catch(exception e)
>           //msgbox(e.message,"Error:"+e.code)
>          success = false
>       endtry
>       release object x
>       return success
>