How do I toggle internet connection on/off

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Is there a way for me to create a two key combination that will toggle my
internet connection on/off? I am right clicking a shortcut to my connection
and choosing "disable". I'd like a less cumbersome method.
Thanks much.
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Rat wrote:

> Is there a way for me to create a two key combination that will toggle
> my internet connection on/off? I am right clicking a shortcut to my
> connection and choosing "disable". I'd like a less cumbersome method.
Hi

You can do it by creating a shortcut that have a keyboard shortcut key,
and let the shortcut point to a VBScript that does the job.


With Shell.Application/VBScript (Win2k and WinXP):

From: Michael Harris
Subject: Re: How to disable-Enable Local area Connection via script
Newsgroups: microsoft.public.scripting.vbscript
Date: 2002-03-25 11:36:10 PST
http://groups.google.co.uk/groups?selm=OcFYOQD1BHA.2848%40tkmsftngp05


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > Is there a way for me to create a two key combination that will toggle
> > my internet connection on/off? I am right clicking a shortcut to my
> > connection and choosing "disable". I'd like a less cumbersome method.
> Hi
>
> You can do it by creating a shortcut that have a keyboard shortcut key,
> and let the shortcut point to a VBScript that does the job.
>
>
> With Shell.Application/VBScript (Win2k and WinXP):
>
> From: Michael Harris
> Subject: Re: How to disable-Enable Local area Connection via script
> Newsgroups: microsoft.public.scripting.vbscript
> Date: 2002-03-25 11:36:10 PST
> http://groups.google.co.uk/groups?selm=OcFYOQD1BHA.2848%40tkmsftngp05
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>


Thank you for the response. I have never worked with a VB script. Can you
give me instructions on how to accomplish this task?
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Rat wrote:

> "Torgeir Bakken (MVP)" wrote:
>>Rat wrote:
>>
>>>Is there a way for me to create a two key combination that will toggle
>>>my internet connection on/off? I am right clicking a shortcut to my
>>>connection and choosing "disable". I'd like a less cumbersome method.
>>
>>You can do it by creating a shortcut that have a keyboard shortcut key,
>>and let the shortcut point to a VBScript that does the job.
>>
>>
>>With Shell.Application/VBScript (Win2k and WinXP):
>>
>>From: Michael Harris
>>Subject: Re: How to disable-Enable Local area Connection via script
>>Newsgroups: microsoft.public.scripting.vbscript
>>Date: 2002-03-25 11:36:10 PST
>>http://groups.google.co.uk/groups?selm=OcFYOQD1BHA.2848%40tkmsftngp05
>
>
> Thank you for the response. I have never worked with a VB script. Can you
> give me instructions on how to accomplish this task?
Hi

1.
Open Notepad.

2.
Paste the script in the link I gave you into the Notepad document.

3.
At the line

sConnectionName = "Local Area Connection"

change "Local Area Connection" to the name you have on
your connection (unless it is "Local Area Connection").

4.
Save the file with a .vbs file extension (e.g. call it
ToggleConnection.vbs)

5.
Run the file by double clicking on it.


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > "Torgeir Bakken (MVP)" wrote:
> >>Rat wrote:
> >>
> >>>Is there a way for me to create a two key combination that will toggle
> >>>my internet connection on/off? I am right clicking a shortcut to my
> >>>connection and choosing "disable". I'd like a less cumbersome method.
> >>
> >>You can do it by creating a shortcut that have a keyboard shortcut key,
> >>and let the shortcut point to a VBScript that does the job.
> >>
> >>
> >>With Shell.Application/VBScript (Win2k and WinXP):
> >>
> >>From: Michael Harris
> >>Subject: Re: How to disable-Enable Local area Connection via script
> >>Newsgroups: microsoft.public.scripting.vbscript
> >>Date: 2002-03-25 11:36:10 PST
> >>http://groups.google.co.uk/groups?selm=OcFYOQD1BHA.2848%40tkmsftngp05
> >
> >
> > Thank you for the response. I have never worked with a VB script. Can you
> > give me instructions on how to accomplish this task?
> Hi
>
> 1.
> Open Notepad.
>
> 2.
> Paste the script in the link I gave you into the Notepad document.
>
> 3.
> At the line
>
> sConnectionName = "Local Area Connection"
>
> change "Local Area Connection" to the name you have on
> your connection (unless it is "Local Area Connection").
>
> 4.
> Save the file with a .vbs file extension (e.g. call it
> ToggleConnection.vbs)
>
> 5.
> Run the file by double clicking on it.
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Thank you. Sorry for my lack of knowledge but i have followed the
instructions and get the following error......"Couldn't find 'Network and
Dial-up Connections' folder"
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Rat wrote:

> Thank you. Sorry for my lack of knowledge but i have followed
> the instructions and get the following error......"Couldn't find
> 'Network and Dial-up Connections' folder"
Hi

In the script, change

Network and Dial-up Connections

to

Network Connections

(two places in the script)


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > Thank you. Sorry for my lack of knowledge but i have followed
> > the instructions and get the following error......"Couldn't find
> > 'Network and Dial-up Connections' folder"
> Hi
>
> In the script, change
>
> Network and Dial-up Connections
>
> to
>
> Network Connections
>
> (two places in the script)
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Sorry,still having trouble,
Now I get a"couldn't find 'Network Connections' folder". I tried re-naming
the sConnectionName = "Local Area Connection" to no avail. Here is what I
have......


Const ssfCONTROLS = 3

sConnectionName = "Local Area Connection"

sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"

set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)

set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "Network Connections" then
set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "Couldn't find 'Network Connections' folder"
wscript.quit
end if

set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next

if oLanConnection is nothing then
msgbox "Couldn't find '" & sConnectionName & "' item"
wscript.quit
end if

bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next

'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit

'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if

'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 1000
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > Thank you. Sorry for my lack of knowledge but i have followed
> > the instructions and get the following error......"Couldn't find
> > 'Network and Dial-up Connections' folder"
> Hi
>
> In the script, change
>
> Network and Dial-up Connections
>
> to
>
> Network Connections
>
> (two places in the script)
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>



Hi,
Sorry but I am still having trouble. After the changes above I get...
"Couldn't find 'Network Connections' folder"

I also tried re-naming the sConnectionName to no avail.
This is what I have so far....

Const ssfCONTROLS = 3

sConnectionName = "Local Area Connection"

sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"

set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)

set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "Network Connections" then
set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "Couldn't find 'Network Connections' folder"
wscript.quit
end if

set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next

if oLanConnection is nothing then
msgbox "Couldn't find '" & sConnectionName & "' item"
wscript.quit
end if

bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next

'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit

'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if

'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 1000

Thank you so much for your help.
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Rat wrote:

> Hi,
> Sorry but I am still having trouble. After the changes above I get...
> "Couldn't find 'Network Connections' folder"
>
> I also tried re-naming the sConnectionName to no avail.
> This is what I have so far....
>
> Const ssfCONTROLS = 3
>
> sConnectionName = "Local Area Connection"
>
> sEnableVerb = "En&able"
> sDisableVerb = "Disa&ble"
>
> set shellApp = createobject("shell.application")
> set oControlPanel = shellApp.Namespace(ssfCONTROLS)
>
> set oNetConnections = nothing
> for each folderitem in oControlPanel.items
> if folderitem.name = "Network Connections" then


You have two spaces in "Network Connections", you must only
have one...




--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > Hi,
> > Sorry but I am still having trouble. After the changes above I get...
> > "Couldn't find 'Network Connections' folder"
> >
> > I also tried re-naming the sConnectionName to no avail.
> > This is what I have so far....
> >
> > Const ssfCONTROLS = 3
> >
> > sConnectionName = "Local Area Connection"
> >
> > sEnableVerb = "En&able"
> > sDisableVerb = "Disa&ble"
> >
> > set shellApp = createobject("shell.application")
> > set oControlPanel = shellApp.Namespace(ssfCONTROLS)
> >
> > set oNetConnections = nothing
> > for each folderitem in oControlPanel.items
> > if folderitem.name = "Network Connections" then
>
>
> You have two spaces in "Network Connections", you must only
> have one...
>
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>


Done. I still get "Couldn't find 'Network Connections' folder"
here's what i have....

Const ssfCONTROLS = 3

sConnectionName = "Local Area Connection"

sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"

set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)

set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "Network Connections" then
set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "Couldn't find 'Network Connections' folder"
wscript.quit
end if

set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next

if oLanConnection is nothing then
msgbox "Couldn't find '" & sConnectionName & "' item"
wscript.quit
end if

bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next

'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit

'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if

'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 1000
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

Rat wrote:

> Done. I still get "Couldn't find 'Network Connections' folder"
> here's what i have....
>
> Const ssfCONTROLS = 3
>
> sConnectionName = "Local Area Connection"
>
> sEnableVerb = "En&able"
> sDisableVerb = "Disa&ble"
>
> set shellApp = createobject("shell.application")
> set oControlPanel = shellApp.Namespace(ssfCONTROLS)
>
> set oNetConnections = nothing
> for each folderitem in oControlPanel.items
> if folderitem.name = "Network Connections" then
Hi

You still have two spaces in the "Network Connections" part
(you only updated the MsgBox text).



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

rat

Distinguished
Aug 1, 2004
58
0
18,630
Archived from groups: microsoft.public.windowsxp.security_admin (More info?)

"Torgeir Bakken (MVP)" wrote:

> Rat wrote:
>
> > Done. I still get "Couldn't find 'Network Connections' folder"
> > here's what i have....
> >
> > Const ssfCONTROLS = 3
> >
> > sConnectionName = "Local Area Connection"
> >
> > sEnableVerb = "En&able"
> > sDisableVerb = "Disa&ble"
> >
> > set shellApp = createobject("shell.application")
> > set oControlPanel = shellApp.Namespace(ssfCONTROLS)
> >
> > set oNetConnections = nothing
> > for each folderitem in oControlPanel.items
> > if folderitem.name = "Network Connections" then
> Hi
>
> You still have two spaces in the "Network Connections" part
> (you only updated the MsgBox text).
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

I missed that...thought that i did that one.
That did it.
Thank you very much for your help....and your patience.