Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #12481

Re: Open network connection (VPN) with vbscript

Newsgroups microsoft.public.scripting.vbscript
Date 2023-05-17 21:04 -0700
References <grizzly.1a8jpm@mail.codecomments.com> <O5E3b42dEHA.3612@TK2MSFTNGP09.phx.gbl> <ethiWI$dEHA.3756@TK2MSFTNGP12.phx.gbl>
Message-ID <9761eeae-dc46-4e8e-8658-1807d2f512ebn@googlegroups.com> (permalink)
Subject Re: Open network connection (VPN) with vbscript
From KAMRAN MANKI <mankikamran6@gmail.com>

Show all headers | View raw


On Sunday, August 1, 2004 at 11:05:08 AM UTC-7, Alex K. Angelopoulos [MVP] wrote:
> Alex K. Angelopoulos [MVP] wrote:
> > grizzly wrote:
> >> I'm trying to open a VPN connection under network connections in WinXP
> >> with VBScript.
> 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
SHIB

Back to microsoft.public.scripting.vbscript | Previous | Next | Find similar


Thread

Re: Open network connection (VPN) with vbscript KAMRAN MANKI <mankikamran6@gmail.com> - 2023-05-17 21:04 -0700

csiph-web