Alex, both of these are wonderful suggestions, a lot further than I'v
ever got in trying to resolve this issue, but still a little flawed.
When run, the VPN connection opens and then asks to connect or cancel.
After you connect, the 2nd script you have suggested, pops up with
bunch of windows which I'm trying to avoid. When you select OK o
those windows, the VPN connection will then initiate a close connectio
box with the option to stay connected. If you select to stay connected
then it's fine. All of these windows will deffinitely confuse m
clients. Is there a better way, or even a way that will halt th
script indeffinitely without asking for user input, so that the entir
VPN session can go along? Thanks again for all your help.

Ian

Alex K. Angelopoulos [MVP] wrote:
> *Alex K. Angelopoulos [MVP] wrote:[color=darkred]
> > grizzly wrote:
>
> After looking through a few old Bakken & Harris posts I decided t
> write a
> more generic method for handling items that "toggle" and may tak
> time to do
> so. Here's a function which can be used for any addressable shel
> namespace
> item; you simply supply it with the namespace index (49 for network
> connections), the item name ("VPN Connection" in our case) and th
> verb
> ("C&onnect" for English language systems).
>
> Option Explicit
> Dim t0: t0 = Timer
> WScript.Echo "Success?", _
> ToggleShellItem(49, "VPN Connection", "C&onnect")
> WScript.Echo timer - t0
>
> Function ToggleShellItem(ByVal namespace, ByVal item, ByVal verb)
> ' Use a shell folder item verb which disappears after use.
> ' Examples are Connect/Disconnect, Enable/Disable pairs.
> ' namespace: numeric ID of the namespace
> ' itemName: name of the item when viewed in the namespace window.
> ' verbName: verb to activate.
> ' The function will find the verb in the item, DoIt, wait
> ' until the verb "disappears" from the verb list, then return True.
> ' If the item or verb is not found, returns False.
> ToggleShellItem = False
> Dim sa: Set sa = CreateObject("Shell.Application")
> Dim items, i
> Set items = sa.Namespace(namespace).Items
> For i = 0 to items.Count - 1
> If LCase( items.Item(i).Name) = LCase(item) Then
> Dim target: set target = items.Item(i)
> Exit For
> End If
> Next
> For i = 0 to target.Verbs.Count - 1
> If LCase(target.Verbs.Item(i).Name) = LCase(verb) Then
> target.Verbs.Item(i).DoIt
> Do While LCase(target.Verbs.Item(i).Name) = LCase(verb)
> WScript.Sleep 500
> Loop
> ToggleShellItem = True
> Exit For
> End If
> Next
> End Function


-
grizzl
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Re: Open network connection (VPN) with vbscript by Alex

Alex
Sun Aug 15 23:30:58 CDT 2004

grizzly wrote:
> Alex, both of these are wonderful suggestions, a lot further than I've
> ever got in trying to resolve this issue, but still a little flawed.
> When run, the VPN connection opens and then asks to connect or cancel.
> After you connect, the 2nd script you have suggested, pops up with a
> bunch of windows which I'm trying to avoid.

What are the windows? You may still have the test echo statements in there;
the single line
ToggleShellItem 49, "VPN Connection", "C&onnect"
with the ToggleShellItem function in the same script will initiate the
connection named "VPN Connection". I'm not sure why you're seeing the
prompt to disconnect after that - are you running everything from a single
script?


When you select OK on
> those windows, the VPN connection will then initiate a close connection
> box with the option to stay connected. If you select to stay connected,
> then it's fine. All of these windows will deffinitely confuse my
> clients. Is there a better way, or even a way that will halt the
> script indeffinitely without asking for user input, so that the entire
> VPN session can go along? Thanks again for all your help.
>
> Ian
>
> Alex K. Angelopoulos [MVP] wrote:
>> *Alex K. Angelopoulos [MVP] wrote:[color=darkred]
>>> grizzly wrote:
>>
>> After looking through a few old Bakken & Harris posts I decided to
>> write a
>> more generic method for handling items that "toggle" and may take
>> time to do
>> so. Here's a function which can be used for any addressable shell
>> namespace
>> item; you simply supply it with the namespace index (49 for network
>> connections), the item name ("VPN Connection" in our case) and the
>> verb
>> ("C&onnect" for English language systems).
>>
>> Option Explicit
>> Dim t0: t0 = Timer
>> WScript.Echo "Success?", _
>> ToggleShellItem(49, "VPN Connection", "C&onnect")
>> WScript.Echo timer - t0
>>
>> Function ToggleShellItem(ByVal namespace, ByVal item, ByVal verb)
>> ' Use a shell folder item verb which disappears after use.
>> ' Examples are Connect/Disconnect, Enable/Disable pairs.
>> ' namespace: numeric ID of the namespace
>> ' itemName: name of the item when viewed in the namespace window.
>> ' verbName: verb to activate.
>> ' The function will find the verb in the item, DoIt, wait
>> ' until the verb "disappears" from the verb list, then return True.
>> ' If the item or verb is not found, returns False.
>> ToggleShellItem = False
>> Dim sa: Set sa = CreateObject("Shell.Application")
>> Dim items, i
>> Set items = sa.Namespace(namespace).Items
>> For i = 0 to items.Count - 1
>> If LCase( items.Item(i).Name) = LCase(item) Then
>> Dim target: set target = items.Item(i)
>> Exit For
>> End If
>> Next
>> For i = 0 to target.Verbs.Count - 1
>> If LCase(target.Verbs.Item(i).Name) = LCase(verb) Then
>> target.Verbs.Item(i).DoIt
>> Do While LCase(target.Verbs.Item(i).Name) = LCase(verb)
>> WScript.Sleep 500
>> Loop
>> ToggleShellItem = True
>> Exit For
>> End If
>> Next
>> End Function *