From 5b5212d014601680378c3ca73957858c7f8247fb Mon Sep 17 00:00:00 2001 From: Lostecho <31339626+IHHII@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:12:40 +0800 Subject: [PATCH] Update toggle_proxy_on_off.vbs --- toggle_proxy_on_off.vbs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/toggle_proxy_on_off.vbs b/toggle_proxy_on_off.vbs index 39c05c8..e638167 100755 --- a/toggle_proxy_on_off.vbs +++ b/toggle_proxy_on_off.vbs @@ -8,7 +8,7 @@ Option Explicit 'Variables & Constants: -Dim ProxySettings_path, VbsScript_filename +Dim ProxySettings_path, VbsScript_filename, Desktop_path VbsScript_filename = "toggle_proxy_on_off.vbs" 'sec; change this value to set how long the message box displays when you toggle the proxy setting Const MESSAGE_BOX_TIMEOUT = 1 @@ -19,7 +19,8 @@ Set WSHShell = WScript.CreateObject("WScript.Shell") 'get the username string for use in path names, since trying to use the "%USERNAME%" variable 'directly in path names throws an error username = WSHShell.ExpandEnvironmentStrings("%USERNAME%") -ProxySettings_path = "C:\Users\" + username + "\Windows_Proxy_Toggler" +ProxySettings_path = createobject("Scripting.FileSystemObject").GetFolder(".").Path +Desktop_path = WSHShell.SpecialFolders("Desktop") 'Determine current proxy setting and toggle to opposite setting proxyEnableVal = wshshell.regread("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable") @@ -53,7 +54,7 @@ End Sub Sub CreateOrUpdateDesktopShortcut(onOrOff) 'create a shortcut Dim shortcut, iconStr - Set shortcut = WSHShell.CreateShortcut("C:\Users\" + username + "\Desktop\Proxy On-Off.lnk") + Set shortcut = WSHShell.CreateShortcut(Desktop_path + "\Proxy On-Off.lnk") 'Set the target path (target file) to run when the shortcut is clicked shortcut.TargetPath = ProxySettings_path + "\" + VbsScript_filename 'Set the working directory. This is necessary in case you ever make this shortcut call a batch @@ -73,4 +74,4 @@ Sub CreateOrUpdateDesktopShortcut(onOrOff) shortcut.IconLocation = ProxySettings_path + "\icons\" + iconStr 'Save the shortcut shortcut.Save -End Sub +End Sub \ No newline at end of file