本文介绍了如何将图标修改脚本与脚本进行集成以切换代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我指的是这篇文章.就像在原始帖子中一样,我有一个代理打开/关闭脚本.
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 ...更多推荐
如何将图标修改脚本与脚本进行集成以切换代理?
发布评论