Shell and wait

Erel

B4X founder
Staff member
Licensed User
Longtime User
The following code allows you to run an external application and wait for it to finish (unlike regular Shell which continues to run immediately).
It requires the Door library: http://www.b4x.com/forum/showthread.php?p=11025

B4X:
Sub Globals
    'Declare the global variables here.

End Sub

Sub App_Start
    'Initialize objects
    process.New1(false)
    process.CreateNew("System.Diagnostics.Process" & process.System_NS)
    StartInfo.New1(false)
    StartInfo.Value = process.GetProperty("StartInfo")
    
    'Usage
    ShellAndWait("iexplore","www.b4x.com")
    Msgbox("After Shell")
End Sub

Sub ShellAndWait(File, Arguments)
    StartInfo.SetProperty("FileName",File)
    StartInfo.SetProperty("Arguments",arguments)
    process.RunMethod("Start")
    process.RunMethod("WaitForExit")
    process.RunMethod("Close")
End Sub
 

Attachments

  • ShellAndWait.sbp
    788 bytes · Views: 464
Top