Results 1 to 3 of 3
  1. #1
    -[Nero..x3's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    15

    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?

  2. #2
    Sazor98's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    X:13 Y:3 Z:7
    Posts
    154
    Reputation
    23
    Thanks
    64
    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.microsof*****m/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
    Last edited by Sazor98; 03-30-2016 at 06:55 AM.

  3. #3
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. [Help] How to read cmd?
    By BestBlitzcrank in forum Visual Basic Programming
    Replies: 2
    Last Post: 03-05-2015, 02:58 PM
  2. [Solved] How To Read A Specific Line From A File ?
    By wilson945766 in forum Visual Basic Programming
    Replies: 4
    Last Post: 01-21-2012, 12:49 AM
  3. Do You Know How To Read Or Convert Rez Files Into Somtin Else?
    By KillerKen013 in forum General Hacking
    Replies: 3
    Last Post: 05-19-2009, 02:20 PM
  4. I know how to read korean combat arms with...
    By skip in forum Combat Arms Hacks & Cheats
    Replies: 2
    Last Post: 08-27-2008, 01:10 PM
  5. [Tutorial] Reading from the CMD line
    By shercipher in forum C++/C Programming
    Replies: 7
    Last Post: 04-04-2006, 12:49 PM