Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    OVPN Win32 Map Network Drive on Logon?

    Scheduled Pinned Locked Moved OpenVPN
    12 Posts 4 Posters 11.3k Views
    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.
    • N
      naughtyusmaximus
      last edited by

      On the OpenVPN Gui page, it lists the following as one of the features:

      "Execute a batch file before/after connecting and before disconnecting."

      I assume I could just add in one of the following commands into a batch file and it would work?

      net use o: \server\share

      So I guess the question is now what do I add in to the ovpn.conf file to tell it to run a batch file?

      1 Reply Last reply Reply Quote 0
      • N
        naughtyusmaximus
        last edited by

        I've searched around, and apparently all I need to do is put my script in the config directory with the name of 'xxxx_up.bat' (where xxxx is the connection name).

        This looks like it will work, but I can't easily test it until I get home from work.

        1 Reply Last reply Reply Quote 0
        • B
          Bredys
          last edited by

          And if you need to hide popup script window, you can set a registry key "show_script_window" in HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN-GUI to "0"
          :D

          1 Reply Last reply Reply Quote 0
          • N
            naughtyusmaximus
            last edited by

            Ok, so I've created the .bat file with the following (sanitized) contents:

            net use z: \\host\sharename mypassword /user:DOMAIN\myusername /persistent:yes
            

            If I run the script manually after connecting to the VPN, it works like a charm.  However it always times out when it is automatically run by OpenVPN.  Is there anything I can do to delay the script by a few seconds?

            1 Reply Last reply Reply Quote 0
            • S
              sullrich
              last edited by

              Download the DOS sleep command:

              http://www.computerhope.com/dutil.htm

              Then use it before the net use command…

              sleep 15
              net use ...

              1 Reply Last reply Reply Quote 0
              • GruensFroeschliG
                GruensFroeschli
                last edited by

                wouldnt the "-route-up cmd" in conjunction with "-route-delay" command from openVPN itself work too?
                (i didnt try it but it might be worth a shot)

                –route-delay [n] [w]
                    Delay n seconds (default=0) after connection establishment, before adding routes. If n is 0, routes will be added immediately upon connection establishment. If –route-delay is omitted, routes will be added immediately after TUN/TAP device open and --up script execution, before any --user or --group privilege downgrade (or --chroot execution.)

                This option is designed to be useful in scenarios where DHCP is used to set tap adapter addresses. The delay will give the DHCP handshake time to complete before routes are added.

                On Windows, --route-delay tries to be more intelligent by waiting w seconds (w=30 by default) for the TAP-Win32 adapter to come up before adding routes.

                --route-up cmd
                    Execute shell command cmd after routes are added, subject to --route-delay.

                See the "Environmental Variables" section below for additional parameters passed as environmental variables.

                Note that cmd can be a shell command with multiple arguments.

                We do what we must, because we can.

                Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • N
                  naughtyusmaximus
                  last edited by

                  I still must be missing something.  If I run my 'net mount' script manually, it works perfectly, but even with delaying the execution of the script in my ovpn config, I end up with this error:

                  "C:\Program Files\OpenVPN\config>net use …(etc)
                  System error 67 has occurred.

                  The network name cannot be found.

                  Wed Jan 09 19:54:39 2008 us=976924 Route script failed: system() returned error
                  code 2
                  Wed Jan 09 19:54:39 2008 us=977080 Initialization Sequence Completed
                  Wed Jan 09 19:54:40 2008 us=12335 Replay-window backtrack occurred [1]"

                  1 Reply Last reply Reply Quote 0
                  • GruensFroeschliG
                    GruensFroeschli
                    last edited by

                    are you using the windows name or the actual IP?

                    We do what we must, because we can.

                    Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

                    1 Reply Last reply Reply Quote 0
                    • N
                      naughtyusmaximus
                      last edited by

                      It doesn't seem to make a difference which I use.  Also, I have a a WINS machine on the VPN side of the LAN which resolves windows host names to their IPs.

                      1 Reply Last reply Reply Quote 0
                      • GruensFroeschliG
                        GruensFroeschli
                        last edited by

                        maybe this helps:
                        http://www.chicagotech.net/troubleshooting/systemerror67.htm

                        We do what we must, because we can.

                        Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

                        1 Reply Last reply Reply Quote 0
                        • N
                          naughtyusmaximus
                          last edited by

                          Like I said though, the script works perfectly if I run it manually, the only time it doesn't work is when it is invoked as part of the oVPN process itself.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.