Call A .bat file from a web server

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Call A .bat file from a web server

#1 Post by Adrianvdh » 16 May 2013 13:11

Hello Everyone I am trying to make an auto-updater for my .bat project (its almost done :)).
So I have a bat file at...

http://mywebsite.com/WM/AppData.bat...
and in the bat file it has...

set "currentversion=1.0"
set "updatedate=2013/05/15"
set "updatefixes=Fixed This, Added This And Removed This"
set "updatefilepath=a URL"
set "changelogmodesize=54,30"

As AppData.bat. Now I would like to call this bat file (No I don't want to download it with wget.exe or anonymously ftp download it. I just want to load it (call it)

echo.
echo Checking for an update...
ping localhost -n 2 >nul
call http://mywebsite.com/WM/AppData.bat

Then I would echo the variable's...

if not "%version%"=="%currentversion%" (
goto updateTrue
) else (
goto updateFalse )

:updateTrue
echo Update = true
echo Version: "%currentversion%", "%updatedate%"
echo.
pause

Thanks for your time :)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Call A .bat file from a web server

#2 Post by foxidrive » 16 May 2013 20:04

Adrianvdh wrote:Hello Everyone I am trying to make an auto-updater for my .bat project (its almost done :)).
So I have a bat file at...

http://mywebsite.com/WM/AppData.bat...
and in the bat file it has...

set "currentversion=1.0"
set "updatedate=2013/05/15"
set "updatefixes=Fixed This, Added This And Removed This"
set "updatefilepath=a URL"
set "changelogmodesize=54,30"

As AppData.bat. Now I would like to call this bat file (No I don't want to download it with wget.exe or anonymously ftp download it. I just want to load it (call it)

echo.
echo Checking for an update...
ping localhost -n 2 >nul
call http://mywebsite.com/WM/AppData.bat


You don't understand how a batch file can work on a remote system. It has to be downloaded onto the local system to be executed.

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Call A .bat file from a web server

#3 Post by Adrianvdh » 17 May 2013 01:51

Ok then is there another way to call/load another type of file from a webserver e.g XML?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Call A .bat file from a web server

#4 Post by foxidrive » 17 May 2013 02:23

The answer is also no, unless you use it in a web browser.

For a file to be loaded in any way it has to be present on the local filesystem. That usually involves downloading a temporary copy and doing what you need, then deleting the temp files.

If you describe your intentions then someone may have ideas for you...

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Call A .bat file from a web server

#5 Post by Adrianvdh » 17 May 2013 06:52

I am trying to make an auto updater. Ok is there a way then to read XML Elements in a XML file then?

P.S could you tell me the wget.exe parameter to download a file and save it to directory...

set dir=%tmp%

wget URL %dir%

Thanks alot :)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Call A .bat file from a web server

#6 Post by foxidrive » 17 May 2013 15:09

Adrianvdh wrote:I am trying to make an auto updater. Ok is there a way then to read XML Elements in a XML file then?

P.S could you tell me the wget.exe parameter to download a file and save it to directory...

set dir=%tmp%

wget URL %dir%



Try this to download the file to the current folder.

cd /d "c:\folder"
wget URL/file.xml

I can't help with your other question until you describe what you need to do.

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Call A .bat file from a web server

#7 Post by Adrianvdh » 17 May 2013 16:30

...
:checkupdate
set "UpdateURL=http://domain.com/WM/AppData.bat"
call "%UpdateURL%"
cls
mode 52,13
echo -Update
echo.
echo Checking for an update...
ping localhost -n 2 >nul
ping /n "%pinglayersnumber%" "%webhost%" >nul
if "%errorlevel%"=="0" goto callupdatefile
if "%errorlevel%"=="1" goto updateinternetconnection1

:callupdatefile
::Get update information
call "%UpdateURL%"


if "%errorlevel%"=="1" goto failedgetupdateinfo
if "%errorlevel%"=="0" (
if "%version%"=="%currentversion%" goto updateFalse
if not "%version%"=="%currentversion%" goto updateTrue )

:updateTrue
set "versionreleasedate1=%updatedate%"
::Take out soon
set "versionreleasedate1=2013/05/12"
set "versionreleasetime1=00:00:00.00"
call :GetInternational
call :GetSecs "%versionreleasedate1%" "%versionreleasetime1%" startsec
call :GetSecs "%date%" "%time%" stopsec
set /a versionday=(%stopsec%-%startsec%)/86400

mode "%changelogmodesize%"
cls
echo -True
echo.
echo There is an update available for Product...
echo The details for the update are as follows:
echo.
if "%versionday%"=="1" (echo Version: %version% [%versionreleasedate1%, %versionday% day ago]
) else if "%versionday%" gtr "1" (echo Version: %version% [%versionreleasedate1%, %versionday% days ago]
) else if "%versionday%"=="0" (echo Version: %version% [%versionreleasedate1%, released today] )
::echo.Version: [%currentversion%, %updatedate%]
echo.Change Log...
echo.%updatefixes%
echo.
echo Update your version of Product?
choice /C yn /N /M "Download it? Y/N: "
if "%autoupdateflag%"=="Disabled" goto infomenu
if "%autoupdateflag%"=="Enabled" goto mainmenu )
if errorlevel 1 (
start "%updatefilepath%"
if "%autoupdateflag%"=="Disabled" goto infomenu
if "%autoupdateflag%"=="Enabled" goto mainmenu )

:updateFalse
cls
echo -False
echo.
echo Your version of Product is up to date...
echo Your version: %version%
echo.
pause
cls
if "%autoupdateflag%"=="Disabled" (
goto infomenu )
if "%autoupdateflag%"=="Enabled" goto mainmenu

:updateinternetconnection1
cls
echo -Disconnected
echo ---- Product ----
echo.
echo Your computer is not connected to the internet...
echo Failed to check for Product update
echo.
pause
cls

Post Reply