title: Does Microsoft change the name of NetConnectionID when I run a VBS file?
body: <p>The following code disable local connection and enable wirless connection, it worked well before.</p>
  
  <p>Recently my windows 7 with 64 has updated, I find the code does't work, why?</p>
  
  <p>BTW, I think that maybe Microsoft change the name of NetConnectionID, but I'm not sure.</p>
  
  <p><strong>my.vbs</strong></p>
  
  <pre><code>Set WMI=GetObject("winmgmts:\\.\root\cimv2")
  Set w=WMI.ExecQuery("select * from WIN32_NetworkAdapter")
  For Each i In w
     If i.NetConnectionID="本地连接" Then     
        i.Disable()    
     End If
    If i.NetConnectionID="无线网络连接" Then     
        i.Enable()    
     End If
  next
  
  WScript.Sleep  3000 
  
  CreateObject("WScript.Shell").run "netsh wlan connect name=weiiPhone6",0
  </code></pre>
  
  <p><strong>Modified Code</strong></p>
  
  <pre><code>Dim retValue
  
  Set WMI=GetObject("winmgmts:\\.\root\cimv2")
  Set w=WMI.ExecQuery("select * from WIN32_NetworkAdapter")
  For Each i In w
     If i.NetConnectionID="本地连接" Then     
        retValue = i.Disable()    
     End If
     If i.NetConnectionID="无线网络连接" Then     
        retValue = i.Enable()    
     End If
     If retValue &lt;&gt; 0 Then
        'Check return value for the specific error.
        MSGBOX retValue
     End If
     retValue = 0
  Next
  
  WScript.Sleep  3000 
  
  CreateObject("WScript.Shell").run "netsh wlan connect name=weiiPhone6",0
  </code></pre>