如何将图标修改脚本与脚本进行集成以切换代理?

编程入门 行业动态 更新时间:2024-10-28 17:21:08
本文介绍了如何将图标修改脚本与脚本进行集成以切换代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我指的是这篇文章.就像在原始帖子中一样,我有一个代理打开/关闭脚本.

I refer to this post. Just as in the original post I have a proxy on/off script.

我需要帮助的地方是将图标更改脚本"(请参阅​​引荐文章)包含到我现有的脚本中,即在哪里

Where I need help is with the inclusion of the "icon change script" (see referral post) into my already existing script, i.e. where would

Set sh = CreateObject("WScript.Shell") lnkfile = sh.SpecialFolders("Desktop") & "\your.lnk" Set lnk = sh.CreateShortcut(lnkfile) If lnk.IconLocation = "C:\path\to\some.ico" Then sh.IconLocation = "C:\path\to\.ico" Else sh.IconLocation = "C:\path\to\some.ico" End If lnk.Save

适合

Option Explicit Dim WSHShell, strSetting Set WSHShell = CreateObject("WScript.Shell") 'Determine current proxy setting and toggle to oppisite setting strSetting = WSHShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable") If strSetting = 1 Then NoProxy Else Proxy End If 'Subroutine to Toggle Proxy Setting to ON Sub Proxy WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD" WScript.Echo "Proxy is On" End Sub 'Subroutine to Toggle Proxy Setting to OFF Sub NoProxy WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD" WScript.Echo "Proxy is Off" End Sub

我对您的答案Ansgar的解释

My interpretation of your answer Ansgar

Option Explicit Dim WSHShell, strSetting Set WSHShell = WScript.CreateObject("WScript.Shell") 'Determine current proxy setting and toggle to oppisite setting strSetting = WSHShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable") lnkfile = WSHShell.SpecialFolders("Desktop") & "\proxypal.lnk" Set lnk = WSHShell.CreateShortcut(lnkfile) If strSetting = 1 Then WSHShell.IconLocation = "C:\path\to\on.ico" NoProxy Else WSHShell.IconLocation = "C:\path\to\off.ico" Proxy End If lnk.Save 'Subroutine to Toggle Proxy Setting to ON Sub Proxy WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD" Wscript.echo "Proxy is On" End Sub 'Subroutine to Toggle Proxy Setting to OFF Sub NoProxy WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD" Wscript.echo "Proxy is Off" End Sub

但是这将返回此错误

第9行 变量未定义:linkfile 800A01F4 MS VBScript运行时错误

line 9 Variable is undefined: linkfile 800A01F4 MS VBScript Runtime Error

推荐答案

这不太复杂.只需在调用用于修改代理设置的函数的位置更改图标即可:

That's not too complicated. Just change the icon where you call the functions that modify the proxy settings:

... strSetting = WSHShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable") lnkfile = WSHShell.SpecialFolders("Desktop") & "\your.lnk" Set lnk = WSHShell.CreateShortcut(lnkfile) If strSetting = 1 Then WSHShell.IconLocation = "C:\path\to\enable.ico" NoProxy Else WSHShell.IconLocation = "C:\path\to\disable.ico" Proxy End If lnk.Save ...

更多推荐

如何将图标修改脚本与脚本进行集成以切换代理?

本文发布于:2023-11-24 08:20:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624452.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   如何将   图标

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!