Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Run .pbk file in my software

    General and Desktop
    2
    14
    888
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      saeidparand last edited by

      Dear friends, I face to a new challenge with QT C++
      I want run .pbk (vpn l2tp ipsec file) run in my code.
      And I don't know how I can run or execute this kind of files and I don't know , how can I pass some parameters such Username / Password / Server(HostName) and.....to this file.
      Is there any one here to help me please?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        That is a data file. I think its a RAS phone book files.
        In older windows, it was handled by
        c:\Windows\system32\Rasdial.exe
        but nowadays there is also
        rasphone -d "VPN connection name"

        In any case, your app cannot just "execute it"
        You need to use native api or QProcess to call a command line to
        do the connection.
        Some also use powerscripts to setup the connection. i seen on google.

        S 1 Reply Last reply Reply Quote 2
        • S
          saeidparand @mrjj last edited by

          @mrjj Dear friends thanks for your help.
          my software get Username / Password and another L2TP/IPsec VPN connection from JSON and then I must pass these data as a parameter to this .pbk file and software connect to the VPN as automatically.
          If I user QProcess I can run and pass parameters to this .pbk file?

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @saeidparand last edited by

            @saeidparand
            Hi
            You would run rasdial with QProcess , pointing to the pbk file.
            yes. you can give user name and password.
            https://ss64.com/nt/rasdial.html

            However, this is not very secure. It would be easy to replace the
            rasdial.exe with an evil program that would then be able to steal the
            username and password.

            S 3 Replies Last reply Reply Quote 1
            • S
              saeidparand @mrjj last edited by

              @mrjj said in Run .pbk file in my software:

              ss

              thanks for your description.
              you said this is not more secure.....
              what is your opinion for solving this problem?
              because security is very important for this software.

              1 Reply Last reply Reply Quote 0
              • S
                saeidparand @mrjj last edited by saeidparand

                @mrjj
                in fact I want to make a VPN connection as L2TP/IPsec in my software background.
                I googled and found , I can use .pbk file and set username / password and host name as parameters in my code.
                How can I handle this problem?
                best regards dear friend.

                1 Reply Last reply Reply Quote 0
                • S
                  saeidparand @mrjj last edited by saeidparand

                  @mrjj
                  I have Written this code :

                  QProcess process;
                  QString program = "F:/dev/wrokspace/QT-PROJECTS/sql_DB/L2TP-Connection.pbk";
                  //QString program = "C:/Users/m/AppData/Local/NextVPN/NextVPN.exe";
                  QStringList arguments = QStringList();
                  
                  arguments<< "[VPN]";
                  arguments<< "MEDIA=rastapi";
                  arguments<< "Port=VPN2-0";
                  arguments<< "Device=WAN Miniport (IKEv2)";
                  arguments<< "DEVICE=vpn";
                  arguments<< "PhoneNumber=123456";
                  QString user="user";
                  QString pass="pass";
                  
                  arguments<< "rasdial \"VPN\" " +user + " " + pass + " /phonebook:\"" + program ;
                  bool ret= process.startDetached(program,arguments);
                  qDebug() << arguments;
                  qDebug() << ret; ==> return false If I call the L2TP-Connection.pbk but If I call the NextVPN.exe returns true and of course I want run .pbk file in background , but this code open a new wizard.
                  

                  How can I solve this problem? :(

                  1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion last edited by mrjj

                    Hi
                    I dont know what NextVPN.exe is.
                    It might take a parameter to be hidden.
                    if not, there is nothing to do about it.

                    rasdial is an exe file and normally not an argument so
                    not sure i understand what you code tries.
                    NextVPN needs other exe to work or why are you give rasdial.exe to next vpn ??

                    1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion last edited by mrjj

                      Hi
                      Had to try it.
                      alt text

                      I took empty pbk file.
                      added a connection called MYNAME with the server settings
                      and did not store username and password
                      then i called it via rasdial
                      rasdial MYNAME username password /PHONEBOOK:e:\secret.pbk
                      and it just connected without show any dialogs etc.

                      S 1 Reply Last reply Reply Quote 1
                      • S
                        saeidparand @mrjj last edited by

                        @mrjj
                        I use this command , unfortunately It doesn't work.
                        It's thrown 623 Error code. even though I use this command in CMD as you wrote.
                        can I use this command in QT
                        system("rasdial ...............")
                        ?

                        1 Reply Last reply Reply Quote 0
                        • mrjj
                          mrjj Lifetime Qt Champion last edited by mrjj

                          Hi

                          error 623 - System could not find the phone book entry for this connection

                          so i think you are just trying random stuff and hope it works.

                          the MYNAME in my example is the actual name of the connection entry in the phone book.
                          you must match the name you used when you created the entry.

                          you can use QProcess to run it as i did in the cmd prompt.
                          system() also works but its considered bad pratice.
                          besides - QProcess give far better feedback options.

                          make sure all data matches up.
                          both entry name and location of the pbk file.

                          S 2 Replies Last reply Reply Quote 1
                          • S
                            saeidparand @mrjj last edited by

                            @mrjj
                            I know that error 623 is about phone book , but I am wonder that pbk file is exist and my path I'm sure is correct even all the input parameters are correct I'm sure but I don't know what the CMD thrown this error code.

                            1 Reply Last reply Reply Quote 0
                            • S
                              saeidparand @mrjj last edited by

                              @mrjj
                              It has solved.
                              thanks for your help.
                              I just copy the .pbk file into this path. windows/system32/rast
                              best regards dear friends

                              mrjj 1 Reply Last reply Reply Quote 2
                              • mrjj
                                mrjj Lifetime Qt Champion @saeidparand last edited by

                                @saeidparand
                                that is good to hear :)

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post