vbscript - How to integrate icon modification script with script to toggle proxy? -


i refer this post. in original post have proxy on/off script.

where need inclusion of "icon change script" (see referral post) existing script, i.e. 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"   sh.iconlocation = "c:\path\to\.ico" else   sh.iconlocation = "c:\path\to\some.ico" end if lnk.save 

fit into

option explicit  dim wshshell, strsetting set wshshell = createobject("wscript.shell")  'determine current proxy setting , toggle oppisite setting strsetting = wshshell.regread("hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable") if strsetting = 1    noproxy else   proxy end if  'subroutine toggle proxy setting on sub proxy   wshshell.regwrite "hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", 1, "reg_dword"   wscript.echo "proxy on" end sub  'subroutine toggle proxy setting off sub noproxy    wshshell.regwrite "hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", 0, "reg_dword"   wscript.echo "proxy off" end sub 

my interpretation of answer ansgar

option explicit  dim wshshell, strsetting set wshshell = wscript.createobject("wscript.shell")   'determine current proxy setting , toggle 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   wshshell.iconlocation = "c:\path\to\on.ico"   noproxy else   wshshell.iconlocation = "c:\path\to\off.ico"   proxy end if lnk.save  'subroutine toggle proxy setting on sub proxy  wshshell.regwrite "hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", 1, "reg_dword" wscript.echo "proxy on" end sub  'subroutine toggle proxy setting off sub noproxy  wshshell.regwrite "hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", 0, "reg_dword" wscript.echo "proxy off" end sub 

how ever returns error
line 9
variable undefined: linkfile
800a01f4
ms vbscript runtime error

that's not complicated. change icon call functions modify 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   wshshell.iconlocation = "c:\path\to\enable.ico"   noproxy else   wshshell.iconlocation = "c:\path\to\disable.ico"   proxy end if lnk.save ...

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -