; RestartNetwork() ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=65822 /* selected.在没有管理员权限的情况下重启 "局域网连接"。 例子: RestartNetwork("Local area connection") 如果省略ConnectionName,包含 "Realtek PCIe "的适配器名称将被选中。 */ RestartNetwork(ConnectionName := "") { ; 在没有管理员权限的情况下重新启动“本地连接” /* DESCRIPTION OF FUNCTION: -- RestartNetwork -- ------------------------------------------------------------------------------------------------------------------- Description : Restart "Local area connection" without admin privileges Link : https://gist.github.com/tmplinshi/431bc80dbbbf93715f4bd3fb704d8eec https://www.autohotkey.com/boards/viewtopic.php?f=6&t=65822 Author : tmplinshi Date : June 29, 2019 AHK-Version : AHK_L License : -- Syntax : -- Parameter(s) : -- Return value : -- Remark(s) : If ConnectionName is omited, the adapter name that contains "Realtek PCIe" will be selected. Dependencies : none KeyWords : Lan, network, COM, connection ------------------------------------------------------------------------------------------------------------------- | EXAMPLE(s) ------------------------------------------------------------------------------------------------------------------- RestartNetwork("Local area connection") */ oShell := ComObjCreate("Shell.Application") oShell.Open("::{7007ACC7-3202-11D1-AAD2-00805FC1270E}") ; Open Network Connections FolderName := oShell.Namespace(0x31).Title ; Find "Network Connections" window Loop { Sleep, 200 for oWin in oShell.Windows { if ( oWin.LocationName = FolderName ) && ( oWin.LocationURL = "" ) && ( InStr(oWin.FullName, "\Explorer.EXE") ) Break, 2 } } oFolder := oWin.Document.Folder for item in oFolder.Items { devName := oFolder.GetDetailsOf(item, 2) if (item.name = ConnectionName) || (ConnectionName = "" && InStr(devName, "Realtek PCIe")) { if InStr(item.Verbs.Item(0).Name, "&B") { item.InvokeVerb("disable") Sleep, 1000 } item.InvokeVerb("enable") break } } oWin.Quit }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)