Sheller Usage Example

Sheller has only three methods, all of which get used whenever you use it. Here is one example of how you might use Sheller in one of your programs.

This snippet of code deletes a list of files from a Banyan server. It uses a Sheller object, Shell, to build and execute a batch file to perform the task. Shell is first initialized to setup a file whose window will automatically close when execution is completed and then commands are added to the batch file to map the Banyan server so that it is available to the PC. Then a list of files to delete is obtained via GetList and Sheller's AddCmd is used to add a delete command for each file into the developing batch file. Finally, Sheller's Run method is used to execute the batch file.
Dim Shell as Sheller   'declare object
  Set Shell as New Sheller   'create object
  Call Shell.Init(AutoClose)   'initialize to autoclose window after execution
  Call Shell.AddCmd("Z:")   'set logged drive to z:
  If SrvrNme <> "" Then   'map foreign server to a drive letter
    Call Shell.AddCmd(SetDrive + " p /x")   'unassign drive so file doesnt end up in wrong place by accident
    Call Shell.AddCmd(SetDrive + " p " + SrvrNme)   'SETDRIVE to proper PCDirectory
    FileList = GetList("*.frm")   'get CSV list of file names
  End
  While FileList <> ""   'loop through CSV list of file names
    T = CSV.StringFrom(FileList)   'pick off file name
    Call Shell.AddCmd("Del " + T)   'build delete command
  Wend
  resultcode = Shell.Run   'execute the accumulated commands