Parent Directory | Revision Log
+ now with "--setup" feature
1 | joko | 1.1 | Attribute VB_Name = "Module_Main" |
2 | Option Explicit | ||
3 | |||
4 | ' see: How To Obtain the IP Address Assigned to a RAS Client | ||
5 | ' http://support.microsoft.com/default.aspx?scid=kb;en-us;160622 | ||
6 | |||
7 | ' see: RasGetProjectionInfo | ||
8 | ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecomm5/html/wce50lrfRasGetProjectionInfo.asp | ||
9 | |||
10 | ' http://home.iprimus.com.au/billmcc/PlatformVB/dun/rasenumentries.htm | ||
11 | ' http://home.iprimus.com.au/billmcc/PlatformVB/dun/raserrorhandler.htm | ||
12 | ' http://www.mentalis.org/apilist/RasEnumEntries.shtml | ||
13 | |||
14 | ' http://www.activevb.de/tipps/tipkat/kat1.html | ||
15 | ' http://www.activevb.de/rubriken/apikatalog/deklarationen/rasenumentries.html | ||
16 | ' http://www.dotnet247.com/247reference/msgs/18/93960.aspx | ||
17 | |||
18 | Public RasEntries As New Collection | ||
19 | |||
20 | Sub Main() | ||
21 | |||
22 | Dim cmdline As New CommandLine | ||
23 | Dim conName As String | ||
24 | joko | 1.2 | Dim rasItem As RasEntryData |
25 | Dim success As Boolean | ||
26 | joko | 1.3 | |
27 | Dim script_name As String, script_args As String | ||
28 | Dim setup_user As String, setup_pass As String | ||
29 | joko | 1.1 | |
30 | ReadRasEntries | ||
31 | cmdline.parse | ||
32 | |||
33 | joko | 1.3 | 'If cmdline.hasSwitch("gui") Then |
34 | ' Form_Main.Show | ||
35 | 'Else | ||
36 | joko | 1.2 | |
37 | joko | 1.3 | ' dial command |
38 | If cmdline.hasSwitch("dial") Then | ||
39 | |||
40 | conName = cmdline.getArgument("dial") | ||
41 | On Error Resume Next | ||
42 | Set rasItem = RasEntries(conName) | ||
43 | If Err.Number = 0 Then | ||
44 | success = RasConnect(rasItem.entryname, rasItem.PhonebookPath) | ||
45 | Else | ||
46 | MsgBox "Unkown RAS-Connection """ & conName & """." | ||
47 | End If | ||
48 | On Error GoTo 0 | ||
49 | |||
50 | ' hangup command | ||
51 | ElseIf cmdline.hasSwitch("hangup") Then | ||
52 | conName = cmdline.getArgument("hangup") | ||
53 | success = RasDisconnect(conName) | ||
54 | 'MsgBox success | ||
55 | |||
56 | 'End If | ||
57 | |||
58 | ' run script | ||
59 | ElseIf cmdline.hasSwitch("script") And success = True Then | ||
60 | script_name = cmdline.getArgument("script") | ||
61 | If script_name <> "" Then | ||
62 | script_args = Chr(34) & DetermineClientIP() & Chr(34) & " " & Chr(34) & DetermineServerIP & Chr(34) | ||
63 | Shell App.Path & "\" & script_name & " " & script_args, vbHide | ||
64 | End If | ||
65 | 'End If | ||
66 | |||
67 | ' setup | ||
68 | ElseIf cmdline.hasSwitch("setup") Then | ||
69 | conName = cmdline.getArgument("setup") | ||
70 | If conName <> "" Then | ||
71 | joko | 1.2 | |
72 | joko | 1.3 | Set rasItem = RasEntries(conName) |
73 | joko | 1.2 | |
74 | joko | 1.3 | If cmdline.hasSwitch("gui") Then |
75 | With Form_Credentials | ||
76 | .ras_connectionName = rasItem.entryname | ||
77 | .ras_phoneBook = rasItem.PhonebookPath | ||
78 | .Show | ||
79 | End With | ||
80 | |||
81 | ElseIf cmdline.hasSwitch("user") And cmdline.hasSwitch("pass") Then | ||
82 | setup_user = cmdline.getArgument("user") | ||
83 | setup_pass = cmdline.getArgument("pass") | ||
84 | SetupRasEntry rasItem.entryname, rasItem.PhonebookPath, setup_user, setup_pass | ||
85 | joko | 1.2 | End If |
86 | joko | 1.3 | |
87 | joko | 1.2 | End If |
88 | joko | 1.3 | End If |
89 | joko | 1.2 | |
90 | joko | 1.3 | 'End If |
91 | joko | 1.1 | |
92 | End Sub | ||
93 | |||
94 | Private Sub ReadRasEntries() | ||
95 | |||
96 | Dim myEntries() As VBRasEntryName | ||
97 | Dim lngCount As Long | ||
98 | Dim rasItem As RasEntryData | ||
99 | |||
100 | lngCount = VBRasGetAllEntries(myEntries) | ||
101 | |||
102 | 'MsgBox lngCount | ||
103 | Dim i As Integer | ||
104 | Dim curEntry As VBRasEntryName | ||
105 | For i = 0 To lngCount - 1 | ||
106 | curEntry = myEntries(i) | ||
107 | |||
108 | Set rasItem = New RasEntryData | ||
109 | rasItem.entryname = curEntry.entryname | ||
110 | rasItem.PhonebookPath = curEntry.PhonebookPath | ||
111 | rasItem.Win2000_SystemPhonebook = curEntry.Win2000_SystemPhonebook | ||
112 | |||
113 | RasEntries.add rasItem, rasItem.entryname | ||
114 | Next i | ||
115 | |||
116 | End Sub |
MailToCvsAdmin">MailToCvsAdmin | ViewVC Help |
Powered by ViewVC 1.1.26 |