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
fit into
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
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
However this returns this error
line 9
Variable is undefined: linkfile
800A01F4
MS VBScript Runtime Error