#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private Directory As String="E:"
Private FileName As String="test.txt"
'Get-Item -Path e:\test.txt | f1 *
Private Script As String=$"Get-ItemProperty -Path ${Directory}\${FileName} | format-list"$
Private res As ShellSyncResult
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
PowerShellScript(Script)
End Sub
Sub Button1_Click
MainForm.Close
End Sub
Public Sub PowerShellScript(s As String) As ResumableSub
's = s.Replace(CRLF, ";").Replace("""", "'")
Dim shl As Shell
shl.InitializeDoNotHandleQuotes("shl", "powershell.exe", Array("-Command", s))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
res.ExitCode = ExitCode
res.StdErr = StdErr
res.StdOut = StdOut
res.Success = Success
If StdErr <> "" Then
Log(StdErr)
If ExitCode = 0 Then res.ExitCode = 1
End If
Dim InfoArray() As String=Regex.Split(CRLF, StdOut)
Log(InfoArray(8))
Return res
End Sub