How to read CMD lines?

Posts 1–3 of 3 · Page 1 of 1
How to read CMD lines?
Hello,
I know this can be an idiot question but I didn't use to code with CMDs.
So lately I've been working with a PPTP VPN Connector and it works fine but yet I need to know if the connection has succeeded or failed and I'll know that from the CMD.
Here's my code:
Code:
            If Not IO.Directory.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT") Then
                IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT")
            End If
            IO.File.WriteAllText((System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT" & "\strOPT.pbk"), "[VPN]" & vbNewLine & "MEDIA=rastapi" & vbNewLine & "Port=VPN2-0" & vbNewLine & "Device=WAN Miniport (IKEv2)" & vbNewLine & "DEVICE=vpn" & vbNewLine & "PhoneNumber=" & host.Text)
            IO.File.WriteAllText((System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT" & "\strOPT.bat"), "rasdial ""VPN"" " & "elmklbz" & " " & "asdasdasdfy" & " /phonebook:" & """" & System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT" & "\strOPT.pbk" & """")
            Dim connect As System.Diagnostics.Process
            connect = New System.Diagnostics.Process()
            connect.StartInfo.FileName = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LagOPT" & "\strOPT.bat"
            connect.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            connect.Start()
            connect.WaitForExit()
After all that I want to copy everything from the CMD has started to a textbox before it exits, how to do so?
i could be wrong but CMD is just like any other process which you can't directly 'interact' with.

instead you would need to perform a string search by scanning the process memory looking for the bytes which then lead to the characters of the string. and that is alot of hassle just for checking a string. maybe make the batch file write a log.text file and output the success string to it?

or maybe check for the IP address when connecting to the VPN successfully

EDIT:

check this
https://msdn.microsoft.com/en-us/lib...code-snippet-4

1 problem i found with this is that i requires me to press any key on the keyboard. and then actually assign the output to the string. maybe its just me idk
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us