in reply to Using OLE to enable/disable network adapters in Windows

One question that immediately comes to my mind is: do the VBscript versions behave in the same way as you observe with your perl translation i.e. equally unreliable starting ?

If so, then I suspect the ROI is, other than a useful exercise in perl coding, minimal and the best you can hope to acheive is that they both i.e. perl & VBscript, perform equally unreliably.

A user level that continues to overstate my experience :-))
  • Comment on Re: Using OLE to enable/disable network adapters in Windows

Replies are listed 'Best First'.
Re^2: Using OLE to enable/disable network adapters in Windows
by teryx510 (Novice) on Oct 02, 2009 at 22:31 UTC

    Heya Bloodnok, thanks for the reply.

    No, the behaviors between the vbscript version I found on the web and my version are a little different. And by that I mean that their version works without fail and mine well...

      Show the VB version, maybe your translation is off :)

        No prob. Here is the original vbscript I was working from. It works every time.

        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 if bEnabled then oDisableVerb.DoIt else oEnableVerb.DoIt end if wscript.sleep 1000