General Help regarding HMG, Compilation, Linking, Samples
Moderator: Rathinagiri
serge_girard
Posts: 3167 Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB 2 DBF
Location: Belgium
Contact:
Post
by serge_girard » Thu Jan 16, 2020 4:30 pm
For my applications I need to know if on the running computer AnyDesk and/or TeamViewer is installed.
In order to find if 'AnyDesk' is installed I do this:
Code: Select all
cANY := GetProgramFilesFolder() + '\ANYDESK\ANYDESK.EXE'
IF FILE(cANY)
MSGINFO('ANYDESK INSTALLED ')
ELSE
MSGINFO('ANYDESK NOT INSTALLED ') // https://anydesk.com/nl
ENDIF
This works fine. When not installed I need to automate the download procedure:
for AnyDesk:
https://download.anydesk.com/AnyDesk.exe
Now download will start after clicking 'Save file'. This I need to do without user intervention whatsoever.
Anybody how to do this?
Thanks, Serge
There's nothing you can do that can't be done...
mlnr
Posts: 126 Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF
Post
by mlnr » Fri Jan 17, 2020 7:33 am
Hi Serge,
Please try this
Code: Select all
DownloadFile("https://download.anydesk.com/AnyDesk.exe?_ga=2.224258847.522008046.1579245845-896270655.1579245845","AnyDesk.exe")
Code: Select all
FUNCTION DownloadFile( cUrl, cFile )
LOCAL oSoap, aRetorno, nHandle, nCont, lOk
lOk := .f.
BEGIN SEQUENCE WITH { |e| Break(e) }
oSoap := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
oSoap:Open( "GET", cUrl, .f. )
oSoap:Send()
aRetorno := oSoap:ResponseBody()
nHandle := fCreate( cFile )
IF ValType( aRetorno ) == "C"
fWrite( nHandle, aRetorno )
ELSE
FOR nCont = 1 TO Len( aRetorno )
fWrite( nHandle, Chr( aRetorno[ nCont ] ) )
NEXT
ENDIF
fClose( nHandle )
oSoap:Close()
lOk := .t.
END SEQUENCE
RETURN lOk
And maybe it's useful link to some parameter.
https://support.anydesk.com/Automatic_Deployment
Best regards,
Gabor
serge_girard
Posts: 3167 Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB 2 DBF
Location: Belgium
Contact:
Post
by serge_girard » Fri Jan 17, 2020 8:41 am
Thanks Gabor! I will try !
Serge
There's nothing you can do that can't be done...
RPC
Posts: 286 Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF
Post
by RPC » Fri Jan 17, 2020 9:32 am
mlnr wrote: ↑ Fri Jan 17, 2020 7:33 am
Hi Serge,
Please try this
Code: Select all
DownloadFile("https://download.anydesk.com/AnyDesk.exe?_ga=2.224258847.522008046.1579245845-896270655.1579245845","AnyDesk.exe")
Code: Select all
FUNCTION DownloadFile( cUrl, cFile )
LOCAL oSoap, aRetorno, nHandle, nCont, lOk
lOk := .f.
BEGIN SEQUENCE WITH { |e| Break(e) }
oSoap := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
oSoap:Open( "GET", cUrl, .f. )
oSoap:Send()
aRetorno := oSoap:ResponseBody()
nHandle := fCreate( cFile )
IF ValType( aRetorno ) == "C"
fWrite( nHandle, aRetorno )
ELSE
FOR nCont = 1 TO Len( aRetorno )
fWrite( nHandle, Chr( aRetorno[ nCont ] ) )
NEXT
ENDIF
fClose( nHandle )
oSoap:Close()
lOk := .t.
END SEQUENCE
RETURN lOk
And maybe it's useful link to some parameter.
https://support.anydesk.com/Automatic_Deployment
Hi mlnr
Thanks for youe code. Can you please tell me what is the significance of "?_ga=2.224258847.522008046.1579245845-896270655.1579245845" appearing in URL. I have found your code works with even with "
https://download.anydesk.com/AnyDesk.exe " command.
Thanks
mlnr
Posts: 126 Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF
Post
by mlnr » Fri Jan 17, 2020 11:03 am
Can you please tell me what is the significance of "?_ga=2.224258847.522008046.1579245845-896270655.1579245845" appearing in URL. I have found your code works with even with "
https://download.anydesk.com/AnyDesk.exe " command.
No. Just copied the download link from the Anyway webpage
Best regards,
Gabor
serge_girard
Posts: 3167 Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB 2 DBF
Location: Belgium
Contact:
Post
by serge_girard » Fri Jan 17, 2020 1:26 pm
Gabor,
I used this working sample:
Code: Select all
#include "hmg.ch"
/* AD.HBC file
inc=yes
head=native
libs=libhpdf
libs=png
libs=hbssl
libs=libeay32
libs=ssleay32
*/
/* AD.HBP file
AD.PRG (this program!)
hbssl.hbc
*/
FUNCTION MAIN()
/***************/
PUBLIC cANY := ''
PUBLIC WshShell := CreateObject("WScript.Shell")
PUBLIC DesktopFolder := WshShell:SpecialFolders("Desktop")
#require "hbtip"
#require "hbssl"
REQUEST __HBEXTERN__HBSSL__
cANY := DesktopFolder + '\ANYDESK.EXE'
IF FILE(cANY)
MSGINFO('ANYDESK allready installed')
ELSE
Get_IP_Via_PS('ANYDESK')
MSGINFO('Ready! ANYDESK installed')
ENDIF
QUIT
FUNCTION Get_IP_Via_PS(XX)
/*************************************/
LOCAL cURL, cHtml, vRet, cX1, XHTTP
XHTTP := 'https://download.anydesk.com/AnyDesk.exe'
cURL := XHTTP
cHtml := Read_URL_SG( cURL )
Buff_To_File(cHtml, cANY)
RETURN
FUNCTION Read_URL_SG( cUrl )
/***************************/
LOCAL oUrl, oCli, cRes := ''
// REQUEST __HBEXTERN__HBSSL__
BEGIN SEQUENCE
oUrl = TUrl():New( cUrl )
IF EMPTY( oUrl )
BREAK
ENDIF
oCli = TIpClientHttp():New( oUrl )
IF EMPTY( oCli )
BREAK
ENDIF
oCli:nConnTimeout = 20000
IF !oCli:Open( oUrl )
BREAK
ENDIF
cRes := oCli:Read()
oCli:Close()
END SEQUENCE
RETURN cRes
FUNCTION Buff_To_File(cBuff, cNEW_FILE)
/*************************************/
LOCAL fh, nLen
fh := FCREATE(cNEW_FILE,0)
IF fh > - 1
nLen := FWRITE(fh, cBuff)
FCLOSE(fh)
IF nLen == LEN(cBuff)
RETURN .T.
ELSE
RETURN .F.
ENDIF
ENDIF
RETURN .F.
This works for Anydesk but not for TeamViewer: I tried this
Code: Select all
XHTTP := 'https://www.teamviewer.com/nl/teamviewer-automatisch-downloaden'
XHTTP := 'https://dl.teamviewer.com'
XHTTP := 'https://download.teamviewer.com/full' // ==> 'TeamViewer_Setup.exe'
Serge
There's nothing you can do that can't be done...
mlnr
Posts: 126 Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF
Post
by mlnr » Fri Jan 17, 2020 3:40 pm
Best regards,
Gabor
serge_girard
Posts: 3167 Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB 2 DBF
Location: Belgium
Contact:
Post
by serge_girard » Sat Jan 18, 2020 9:10 am
Thanks Gabor, this works fine!
Serge
There's nothing you can do that can't be done...