Const ssfCONTROLS = 3
'This is the name of the network connection
sConnectionName = "Wireless Network Connection"
sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"
'Enter start time in seconds (86400 seconds in a day)
startTime = 32400
endTime = 61200
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",0,"Error"
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",0,"Error"
wscript.Quit
End if
bEnabled = True
Set oEnableVerb = nothing
Set oDisableVerb = nothing
For Each Verb in oLanConnection.verbs
If verb.name = sEnableVerb then
Set oEnableVerb = verb
bEnabled = False
Exit For
ElseIf verb.name = sDisableVerb then
set oDisableVerb = verb
bEnabled = True
Exit For
End if
Next
If bEnabled = False then
oEnableVerb.DoIt
wscript.Sleep 5000
End if
wscript.Sleep 1000
l = 1
Do Until l = 0
Do Until timer < startTime Or timer > endTime
'adjust sleep time as needed; in reality anything above 1ms is going to have little impact on performance
wscript.Sleep 10000
Loop
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",0,"Error"
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",0,"Error"
wscript.Quit
End if
bEnabled = True
Set oEnableVerb = nothing
Set oDisableVerb = nothing
For Each Verb in oLanConnection.verbs
If verb.name = sEnableVerb then
Set oEnableVerb = verb
bEnabled = False
Exit For
ElseIf verb.name = sDisableVerb then
set oDisableVerb = verb
bEnabled = True
Exit For
End if
Next
If bEnabled = True then
oDisableVerb.DoIt
wscript.Sleep 5000
End if
wscript.Sleep 1000
Do Until timer > startTime And timer < endTime
'adjust sleep time as needed; in reality anything above 1ms is going to have little impact on performance
wscript.Sleep 10000
Loop
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",0,"Error"
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",0,"Error"
wscript.Quit
End if
bEnabled = True
Set oEnableVerb = nothing
Set oDisableVerb = nothing
For Each Verb in oLanConnection.verbs
If verb.name = sEnableVerb then
Set oEnableVerb = verb
bEnabled = False
Exit For
ElseIf verb.name = sDisableVerb then
set oDisableVerb = verb
bEnabled = True
Exit For
End if
Next
If bEnabled = False then
oEnableVerb.DoIt
wscript.Sleep 5000
End if
wscript.Sleep 1000
Loop