Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy function #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions bin/autoupdate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,19 @@ if errorlevel 1 (
goto :checkversion
)
:waitnetwork
echo [.] Wait for network connection is available...
echo [-] Network test failed...
::ask user about proxy
echo.
echo [*] If you want to use proxy , please enter the adress here.
echo [*] e.g. http://127.0.0.1:12345
echo [*] If not , just press Enter , we will try it again.
set /p proxy=
if defined proxy (
echo set proxy successfully : %proxy%
goto :checkversion
) else (
echo [*] retrying...
)
ping 127.0.0.1 -n 11>nul
set /a retry_network_check=retry_network_check+1
:: wait for a maximum of 5 minutes
Expand All @@ -314,7 +326,7 @@ echo.
echo [*] get version info of autoupdate.bat from GitHub...
echo -^> %autoupdate_ver_url%
for /f "tokens=* usebackq" %%a in (
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %autoupdate_ver_url% %autoupdate_ver%`
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %autoupdate_ver_url% %autoupdate_ver% %proxy%`
) do (
set "download_status=%%a"
)
Expand All @@ -333,7 +345,7 @@ echo [+] New version 'v.%autoupdate_online_version%' of autoupdate.bat available
echo [*] Download new version of autoupdate.bat from GitHub...
echo -^> %autoupdate_url%
for /f "tokens=* usebackq" %%a in (
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %autoupdate_url% %autoupdate_new_bat%`
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %autoupdate_url% %autoupdate_new_bat% %proxy%`
) do (
set "download_status=%%a"
)
Expand All @@ -357,7 +369,7 @@ echo.
echo [*] Download latest version of rdpwrap.ini from GitHub...
echo -^> %rdpwrap_ini_url%
for /f "tokens=* usebackq" %%a in (
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %rdpwrap_ini_url% %rdpwrap_new_ini%`
`cscript //nologo "%~f0?.wsf" //job:saveWebBinary %rdpwrap_ini_url% %rdpwrap_new_ini% %proxy%`
) do (
set "download_status=%%a"
)
Expand Down Expand Up @@ -391,9 +403,9 @@ exit /b
<package>
<job id="saveWebBinary"><script language="VBScript">
Set args = WScript.Arguments
WScript.Echo SaveWebBinary(args(0), args(1))
WScript.Echo SaveWebBinary(args(0), args(1), args(2))
Wscript.Quit
Function SaveWebBinary(strUrl, strFile) 'As Boolean
Function SaveWebBinary(strUrl, strFile, strProxy) 'As Boolean
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const ForWriting = 2
Expand All @@ -406,7 +418,13 @@ exit /b
If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "GET", strURL, False

' Set proxy if provided
If strProxy <> "" Then
web.SetProxy 2, strProxy
End If

web.Open "GET", strUrl, False
web.Send
If Err.Number <> 0 Then
SaveWebBinary = False
Expand Down Expand Up @@ -442,6 +460,7 @@ exit /b
End If
SaveWebBinary = True
End Function

</script></job>
<job id="getFileVersion"><script language="VBScript">
Set args = WScript.Arguments
Expand Down