Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12481
| X-Received | by 2002:a05:6214:b93:b0:61a:facb:3618 with SMTP id fe19-20020a0562140b9300b0061afacb3618mr451808qvb.9.1684382664496; Wed, 17 May 2023 21:04:24 -0700 (PDT) |
|---|---|
| X-Received | by 2002:a05:6808:3794:b0:394:4a6b:aa91 with SMTP id cu20-20020a056808379400b003944a6baa91mr260198oib.6.1684382664138; Wed, 17 May 2023 21:04:24 -0700 (PDT) |
| Path | csiph.com!1.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail |
| Newsgroups | microsoft.public.scripting.vbscript |
| Date | Wed, 17 May 2023 21:04:23 -0700 (PDT) |
| In-Reply-To | <ethiWI$dEHA.3756@TK2MSFTNGP12.phx.gbl> |
| Injection-Info | google-groups.googlegroups.com; posting-host=223.123.100.3; posting-account=Yk6hzAoAAACPBb05nUA-KznMlWPka_Ye |
| NNTP-Posting-Host | 223.123.100.3 |
| References | <grizzly.1a8jpm@mail.codecomments.com> <O5E3b42dEHA.3612@TK2MSFTNGP09.phx.gbl> <ethiWI$dEHA.3756@TK2MSFTNGP12.phx.gbl> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <9761eeae-dc46-4e8e-8658-1807d2f512ebn@googlegroups.com> (permalink) |
| Subject | Re: Open network connection (VPN) with vbscript |
| From | KAMRAN MANKI <mankikamran6@gmail.com> |
| Injection-Date | Thu, 18 May 2023 04:04:24 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| Xref | csiph.com microsoft.public.scripting.vbscript:12481 |
Show key headers only | 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
Re: Open network connection (VPN) with vbscript KAMRAN MANKI <mankikamran6@gmail.com> - 2023-05-17 21:04 -0700
csiph-web