Saturday, April 21, 2007

Microsoft VPN Client Setup

I don't want to focus on how to deploy application since there are number of sites out there but this is less of an install and more of setting up a client. We have laptop and remote users. At image time they are automatically placed in a unique collection. Once in the Microsoft VPN client is setup on their system. Here is how I do it. First I setup the connection manually, place a shortcut on your desktop. Then I pull out the connection information of the link.

------------------from rasphone.pbk --------vpn.txt-----------
[Corporate-VPN]
Encoding=1
Type=2
AutoLogon=0
UseRasCredentials=1
DialParamsUID=19215656
Guid=146A6DB03341F147B8F58280E0E2E729
BaseProtocol=1
VpnStrategy=2
ExcludedProtocols=0
LcpExtensions=1
----------------------------
Here just the beginning of the file, there is no need for me to place the whole file since your settings would be different. The Guid is random to your system.
This section is stored in a file called VPN.txt. Next I copy the link file to my package folder (corp-vpn.lnk)

Lastly I have this vbscript to run and complete the setup.
--------vpn.vbs-------------------
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strFile, strText
strFileOrig = "C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"
strFileData = "vpn.txt"
set objFile = nothing
set objFolder = nothing
Const ForAppending = 8
Const ForReading = 1


Set objFSO= CreateObject("Scripting.FileSystemObject")
If not objFSO.FileExists(strFileOrig) Then
objFSO.CreateTextFile strFileOrig, False

end if

Set objOrigFile = objFSO.OpenTextFile(strFileorig, ForAppending, True)
Set objVpngFile = objFSO.OpenTextFile(strFileData, ForReading)

Do Until objVpngFile.AtEndOfStream
strCharacters = objVpngFile.Read(1)
objOrigFile.Write(strCharacters)
Loop
objOrigFile.Close

'copy link over
set Copyfile = objFSO.GetFile("corp-vpn.lnk")
Copyfile.copy ("C:\Documents and Settings\All Users\Desktop\")
-----------------------------

You have now setup a MS Vpn connection for the computer.
The only tricky part is the GUID and getting the lnk file to move and maintain its connection to your vpn connection.

This makes setting up a VPN for remote users easy at provision time, no more walking users through it and no more manually doing it.
I don't consider this application installation since there is not setup.exe or install.msi.

Use / modify as needed.