Just in case you like to use dirty quick work with cmd then following might be useful. This sample code sends email through Powershell.
I suggest the example that Roland Smith talks about is better way.
String psPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
Integer li_FileNum
String theCmd
li_FileNum = FileOpen("C:\Temp\cmd.ps1", LineMode!, Write!, LockWrite!, Replace!)
theCmd = "$EmailFrom = ~"" + SendFrom.Text + "~""
FileWrite(li_FileNum, theCmd)
theCmd = "$EmailTo = ~"" + SendTo.Text + "~""
FileWrite(li_FileNum, theCmd)
theCmd = "$Subject = ~""+Subject.Text+"~""
FileWrite(li_FileNum, theCmd)
theCmd = "$Body = ~""+ Msg.Text + "~""
FileWrite(li_FileNum, theCmd)
theCmd = "$SMTPServer = ~"smtp.gmail.com~""
FileWrite(li_FileNum, theCmd)
theCmd = "$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)"
FileWrite(li_FileNum, theCmd)
theCmd = "$SMTPClient.EnableSsl = $true"
FileWrite(li_FileNum, theCmd)
theCmd = "$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(~"fartonheart@gmail.com~", ~"goldplated123~");"
FileWrite(li_FileNum, theCmd)
//theCmd = "$emailattachment = ~"c:\temp\datawindow.pdf~""
//FileWrite(li_FileNum, theCmd)
//
//theCmd = "$attachment = New-Object System.Net.Mail.Attachment($emailattachment, ~'text/plain~')"
//FileWrite(li_FileNum, theCmd)
//
//theCmd = "$Attachments.Add($attachment)"
//FileWrite(li_FileNum, theCmd)
//
theCmd = "$IsBodyHTML = $false"
FileWrite(li_FileNum, theCmd)
theCmd = "$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)"
FileWrite(li_FileNum, theCmd)
FileClose(li_FileNum)
int li_rc
string ls_command
string ls_directory
ls_directory = "C:\temp"
ls_command = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "&'
ls_command += " '" + ls_directory + "\cmd.ps1' "
li_rc = Run ( ls_command, Minimized! )
My case I want to run aws powershell command and want to read output
https://www.topwizprogramming.com/freecode_runandwait.html