### Run DOS Shell Commands

To run DOS Shell Commands, use the jShell Library.
Note: Programs are always started asynchronously. The ProcessComplete event is raised when the process completes.
Example Show the DOS Shell
`Sub mnuShellCommandShell_Action
Private shl As Shell
' Evenname, Executable, Arguments
shl.Initialize("shl", "cmd.exe", Array As String("/c", "start"))
Try
' Run with disabled timeout
shl.Run(-1)
Catch
Log(LastException.Message)
End Try
End Sub`
Example List Files
' List the files including subfolders for the current folder and write output to textfile
`Sub buttonShellDOSListFiles_Action
Private shl As Shell
Dim params As List: params.Initialize
params.Add("/c")
params.Add("start")
params.Add("dir")
params.Add("/B/S")
params.Add("*.*")
params.Add(">a.txt")
shl.Initialize("shl", "cmd.exe", params)
shl.WorkingDirectory = File.DirApp
shl.Run(-1)
End Sub`
'Example showing how to run a DOS batchfile
'File to run = a.bat, content a.bat:
' del a.txt
' dir /b/s *.* > a.txt
' type a.txt
' exit
`Sub buttonShellDOSBatch_Action
Private shl As Shell
Dim params As List: params.Initialize
params.Add("/c")
params.Add("start")
params.Add("a.bat")
shl.Initialize("shl", "cmd.exe", params)
shl.WorkingDirectory = File.DirApp
shl.Run(-1)
End Sub`

Changed: , Category: Shell, File: T6C248M1790.htm, ID: 1790