namespace com.net
import com;

//自动启用、禁用网卡 
function reset(enable, sConnectionName /*如果不指定网卡连接名，则重置所有网卡*/ ){  
	var shellApp = com.CreateObject("Shell.Application") 
	var oControlPanel = shellApp.Namespace(3)  
	var oLanConnection; 
	for index,folderitem in com.each( oControlPanel.items  ) {   
		if (folderitem.name == "网络和拨号连接" || folderitem.name == "Network Connections" ){ 
				for index,connItem in com.each(folderitem.GetFolder.items  ) {  
				 
					if (!sConnectionName or ..string.lower(connItem.name) == ..string.lower(sConnectionName)  ){
							oLanConnection =  connItem; 
	    					for index,verb in com.each(oLanConnection.verbs  ) {  
								vname = ..string.lower(verb.name)
								//..io.print(vname)
								if(  enable && ( ..string.startWith(vname,"en&") || ..string.startWith(vname,"启用") )  ){
									verb.DoIt()
									//..io.print("启用成功")
								} 
								else if( !enable && ( ..string.startWith(vname,"disa&") || ..string.startWith(vname,"禁用") ) ) {
									verb.DoIt()
									//..io.print("禁用成功")
								}
							
							}
							//break;
						} 
					}
				break;
		} 
	}
 	 
	if( sConnectionName && !oLanConnection ) { 
		win.msgbox("未找到 '" + sConnectionName +  "' item" ) 
		return;
	}
	 
 	
	sleep(  500  )
	
}

/*intellisense(com.net)
reset(true) = 启用所有网卡连接
reset(true,"__") = 启用指定网卡连接
reset(false) = 禁用所有网卡连接
reset(false,"__") = 禁用指定网卡连接 
end intellisense*/
