Reputation: 623
I've been coding a batch program (Windows 8) that detects the version of another program I'm running automatically. I'd like to make it so that when anybody else anywhere uses the program, it still detects properly.
I've come up with a solution, to have the batch file read text from a url, and set it into a variable in the batch file itself. However, I have only come up with two ways to do this.
I could download the text directly from http://foo.com/example.html. The real website I'm using's html code looks like this:
v.1.0.0
That is the actual code, there is no formatting whatsoever. I could also download the html file itself, and have batch convert into another format, .txt, or .xyz. I do not want to use an external program, I don't want others to have to install programs to get mine to work.
So essentially, I want a way to download the text from this page, and save it as newestversion.adv file in the same directory as this batch file doing this. From here, I know what to do: The other program will call this batch file to get the newest version, and if it is not the same as the program's defined version, it sends out an echo message.
Thanks in advance!
Upvotes: 0
Views: 3119
Reputation: 41234
Here is a batch file that uses VBS and it works here.
@echo off
>"%temp%\geturl.vbs" echo Set objArgs = WScript.Arguments
>>"%temp%\geturl.vbs" echo url = objArgs(0)
>>"%temp%\geturl.vbs" echo pix = objArgs(1)
>>"%temp%\geturl.vbs" echo With CreateObject("MSXML2.XMLHTTP")
>>"%temp%\geturl.vbs" echo .open "GET", url, False
>>"%temp%\geturl.vbs" echo .send
>>"%temp%\geturl.vbs" echo a = .ResponseBody
>>"%temp%\geturl.vbs" echo End With
>>"%temp%\geturl.vbs" echo With CreateObject("ADODB.Stream")
>>"%temp%\geturl.vbs" echo .Type = 1 'adTypeBinary
>>"%temp%\geturl.vbs" echo .Mode = 3 'adModeReadWrite
>>"%temp%\geturl.vbs" echo .Open
>>"%temp%\geturl.vbs" echo .Write a
>>"%temp%\geturl.vbs" echo .SaveToFile pix, 2 'adSaveCreateOverwrite
>>"%temp%\geturl.vbs" echo .Close
>>"%temp%\geturl.vbs" echo End With
cscript /nologo "%temp%\geturl.vbs" http://adventureversionget.6te.net/AdventureVersion.html newestversion.adv 2>nul
del "%temp%\geturl.vbs"
Upvotes: 0
Reputation: 37569
@ECHO OFF &SETLOCAL
for /f %%a in ('wget -O- http://adventureversionget.6te.net/AdventureVersion.html 2^>nul') do (echo %%a)>newestversion.adv
Upvotes: 1