How can I programmatically create a Windows VPN connection?

后端 未结 7 905
小鲜肉
小鲜肉 2021-02-01 22:23

I have a support environment where we connect to many of our customers\' systems using VPN and Remote Desktop. Right now, support personnel have to manually set up the VPN conne

7条回答
  •  [愿得一人]
    2021-02-01 23:06

    You need a batch script to connect to a VPN that is set up on the base machine. I had a similar problem to deal with a while ago and I found this and this link to be helpful. I have used this solution (first link) in the past so it works but I don't have the batch script anymore.

    1.) Include rasphone.pbk in your script (under C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\ in XP. under C:\Users\USERNAME\AppData\Roaming\Microsoft\Network\Connections\Pbk in Vista)

    2.) Set working directory to a variable name so you can return to it

    3.) Move to the directory where the phonebook is stored using variable names based on the user profile

    4.) Test that the phone book is there, if it is, rename it to rasphone.pbk.bk, then xcopy from the script location (as saved in variable) the new phone book to the new place.

    5.) Connect.

    6.) When ready, disconnect and overwrite the phone book with your settings in with the original file if it is there, else simply delete the phone book.

提交回复
热议问题