'-- Network setup script
'--

 cr = +chr(13)+chr(10) 
 L_Welcome_MsgBox_Message_Text   = _
  "Укажите какие пункты настройки необходимо выполнить:"&cr&_
  "1. Настроить маршрутизацию "&cr&_
  "2. Создать PPTP подключение к 'ASTRA'"
 L_Welcome_MsgBox_Title_Text = "CуперМегаСкрибд (с) спижжен :)"

Private Sub createLink(CName)
	Const ssfCONNECTIONS = &H0031
	Const ssfDESKTOP = &H0019 ' <- All Users, Current user: &H0000

	Dim objShell
	Dim objFolderConnections
	Dim objFolderDesktop
	Dim objSubFolder

	Set ObjShell = WScript.CreateObject("Shell.Application")
	Set objFolderConnections = objShell.NameSpace(ssfCONNECTIONS)
   	Set objFolderDesktop = objShell.NameSpace(ssfDESKTOP)

	If (Not objFolderConnections Is Nothing) and (Not objFolderDesktop Is Nothing) Then
    		For Each objSubFolder In objFolderConnections.Items
        		If objSubFolder.Name = CName Then
            			objFolderDesktop.CopyHere objSubFolder
        		End If
    		Next
	End If

	Set objFolderDesktop = Nothing
	Set objFolderConnections = Nothing
	Set objShell = Nothing
End Sub

 con_entry = "[ASTRA]"&cr&_
            "Encoding=1"&cr&_
            "Type=2"&cr&_
            "AutoLogon=0"&cr&_
            "UseRasCredentials=1"&cr&_
            "DialParamsUID=315453"&cr&_
            "Guid=CC34DB8F83C00649A4153A152484B0CB"&cr&_
            "BaseProtocol=1"&cr&_
            "VpnStrategy=2"&cr&_
            "ExcludedProtocols=0"&cr&_
            "LcpExtensions=1"&cr&_
            "DataEncryption=8"&cr&_
            "SwCompression=1"&cr&_
            "NegotiateMultilinkAlways=0"&cr&_
            "SkipNwcWarning=0"&cr&_
            "SkipDownLevelDialog=0"&cr&_
            "SkipDoubleDialDialog=0"&cr&_
            "DialMode=1"&cr&_
            "DialPercent=75"&cr&_
            "DialSeconds=120"&cr&_
            "HangUpPercent=10"&cr&_
            "HangUpSeconds=120"&cr&_
            "OverridePref=15"&cr&_
            "RedialAttempts=3"&cr&_
            "RedialSeconds=60"&cr&_
            "IdleDisconnectSeconds=0"&cr&_
            "RedialOnLinkFailure=1"&cr&_
            "CallbackMode=0"&cr&_
            "CustomDialDll="&cr&_
            "CustomDialFunc="&cr&_
            "CustomRasDialDll="&cr&_
            "AuthenticateServer=0"&cr&_
            "ShareMsFilePrint=0"&cr&_
            "BindMsNetClient=0"&cr&_
            "SharedPhoneNumbers=0"&cr&_
            "GlobalDeviceSettings=0"&cr&_
            "PrerequisiteEntry="&cr&_
            "PrerequisitePbk="&cr&_
            "PreferredPort=VPN6-0"&cr&_
            "PreferredDevice=Р_РёР_РёРїР_С_С' WAN (L2TP)"&cr&_
            "PreferredBps=0"&cr&_
            "PreferredHwFlow=1"&cr&_
            "PreferredProtocol=1"&cr&_
            "PreferredCompression=1"&cr&_
            "PreferredSpeaker=1"&cr&_
            "PreferredMdmProtocol=0"&cr&_
            "PreviewUserPw=1"&cr&_
            "PreviewDomain=0"&cr&_
            "PreviewPhoneNumber=0"&cr&_
            "ShowDialingProgress=1"&cr&_
            "ShowMonitorIconInTaskBar=1"&cr&_
            "CustomAuthKey=-1"&cr&_
            "AuthRestrictions=872"&cr&_
            "TypicalAuth=2"&cr&_
            "IpPrioritizeRemote=0"&cr&_
            "IpHeaderCompression=0"&cr&_
            "IpAddress=0.0.0.0"&cr&_
            "IpDnsAddress=0.0.0.0"&cr&_
            "IpDns2Address=0.0.0.0"&cr&_
            "IpWinsAddress=0.0.0.0"&cr&_
            "IpWins2Address=0.0.0.0"&cr&_
            "IpAssign=1"&cr&_
            "IpNameAssign=1"&cr&_
            "IpFrameSize=1006"&cr&_
            "IpDnsFlags=0"&cr&_
            "IpNBTFlags=1"&cr&_
            "TcpWindowSize=0"&cr&_
            "UseFlags=0"&cr&_
            "IpSecFlags=0"&cr&_
            "IpDnsSuffix="&cr&_
            "NETCOMPONENTS="&cr&_
            "ms_server=0"&cr&_
            "ms_msclient=0"&cr&_
            "ms_psched=1"&cr&_
            "cntx_vpcnets2=0"&cr&_
            "MEDIA=rastapi"&cr&_
            "Port=VPN6-0"&cr&_
            "Device=Р_РёР_РёРїР_С_С' WAN (L2TP)"&cr&_
            "DEVICE=vpn"&cr&_
            "PhoneNumber=10.109.101.41"&cr&_
            "AreaCode="&cr&_
            "CountryCode=1"&cr&_
            "CountryID=1"&cr&_
            "UseDialingRules=0"&cr&_
            "Comment="&cr&_
            "LastSelectedPhone=0"&cr&_
            "PromoteAlternates=0"&cr&_
            "TryNextAlternateOnFail=1"&cr

 options =  InputBox(L_Welcome_MsgBox_Message_Text, _
               L_Welcome_MsgBox_Title_Text, _
	       "12" )
 If options = "" Then
   WScript.Quit
 End If

 Dim WSHShell, fso, fh, AUDesktop, lnk, pbk

 Set WSHShell = WScript.CreateObject("WScript.Shell")


 If InStr(options, "1") > 0 then
	' Routing
	WShShell.Run "route add -p 172.18.18.0 mask 255.255.255.0 172.18.18.34"
	WShShell.Run "route add -p 10.5.0.0 mask 255.255.0.0 172.18.18.34"
 end if

 If InStr(options, "2") > 0 then
 	' PPTP
 	WShShell.Run "rasphone -r ""ASTRA Connection""", 7, true

 	Set fso = CreateObject("Scripting.FileSystemObject")
 	pbk = "%AllUsersProfile%\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"
 	pbk = WSHShell.ExpandEnvironmentStrings(pbk)

 	Set fh = fso.OpenTextFile(pbk, 8, true)
 	fh.Write(con_entry)
 	fh.Close

 	' Ярлык
	createLink("ASTRA")

	' WShShell.Run "explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
 end if

