cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
J_anitha
Level 8

Automatic download from web, at run-time

Hi,

I am working on IS 2009 project, where I need to download a few components from web and install at runtime. How can I do it without user interaction? :confused:

Thanks in advance,
Anitha
Labels (1)
0 Kudos
(22) Replies
sandeep_madhu14
Level 6

Hi,
do you mean silent installation ....of your application..
thanks
madhu
0 Kudos
J_anitha
Level 8

Not silent install. We wanted to give a url, on click of which can download from web and start on the PC.
0 Kudos
sandeep_madhu14
Level 6

Hi Anitha,

Check The Following Code If it is helpful to you ...

As Per Your requirement the following steps are to be done...
1) First u have to check whether there is internetConection are not..on End User Machine..

For that Following Code will chk Internet Connection availability:

//defining function prototype

prototype Wininet.InternetGetConnectedState(POINTER, NUMBER);

NUMBER nResult,bInternet,dwState;//defining variables required

nResult = UseDLL (WINSYSDIR ^ "Wininet.dll");
if((bInternet = (InternetGetConnectedState(&dwState, 0) = 0)) = TRUE)then
MessageBox("Internet Connection Available",INFORMATION);
else
MessageBox("Internet Connection UnAvailable",INFORMATION);
abort;
endif;
UnUseDLL ("Wininet.dll");

2)You have to check which type of browser the end user is using like ..INTERNETEXPLORER,FIREFOX..etc

I am working on this ..if i get solution i will report to you..

3)Dynamically downloading the url which you are giving during installation fro m the web..

For that u chk following code:

prototype void FILEDOWNLOAD();//defining function prototype

//Implementing function

function void FILEDOWNLOAD()
STRING szInstallPATH;
begin
//here u give the url which i want to download at runtime
//Forexampple i have given www.google.com

szInstallPATH = WINDISK ^ "Program Files\\Internet Explorer\\IEXPLORE.EXE www.google.com";


if (LaunchAppAndWait("",szInstallPATH , LAAW_OPTION_WAIT) < 0) then
MessageBox("Error while downloading", WARNING);

else
MessageBox("Downloaded Successfully",INFORMATION);
endif;
end;

4)Call this function where u required in the installscript...

Here is the complete code...


#include "ifx.h"



//Defining Controls
#define Next 1
#define Cancel 9
#define Back 12


//Definig Function prototype for CustomDialog sdBrowseFolder


prototype Wininet.InternetGetConnectedState(POINTER, NUMBER);
prototype void FILEDOWNLOAD();

function OnFirstUIBefore()
NUMBER nResult, nSetupType, bInternet,dwState;
STRING svPath;
begin


svPath="c:\\Program Files\\Temp1";
nSetupType = TYPICAL;
nResult = UseDLL (WINSYSDIR ^ "Wininet.dll");
if((bInternet = (InternetGetConnectedState(&dwState, 0) = 0)) = TRUE)then
MessageBox("Internet Connection Available",INFORMATION);
else
MessageBox("Internet Connection UnAvailable",INFORMATION);
abort;
endif;
UnUseDLL ("Wininet.dll");

FILEDOWNLOAD();//calling the method

Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;

szTitle = "";
svName = "";
svCompany = "";


end;
function void FILEDOWNLOAD()
STRING szInstallPATH;
begin
szInstallPATH = WINDISK ^ "Program Files\\Internet Explorer\\IEXPLORE.EXE www.google.com";
// szInstallPATH =IEXPLORE.EXE "www.google.com";
//szInstallPATH=SRCDIR ^ "c:\Program Files\Internet Explorer\IEXPLORE.EXE\ WWW.google.com ";
if (LaunchAppAndWait("",szInstallPATH , LAAW_OPTION_WAIT) < 0) then
MessageBox("Error while downloading", WARNING);

else
MessageBox("Downloaded Successfully",INFORMATION);
endif;
end;

if its useful to your application use this code....
Thanks
Madhu.
0 Kudos
sandeep_madhu14
Level 6

hi anitha,
Is it heplful the code which i have sent..
thanks
madhu
0 Kudos
J_anitha
Level 8

thanks Madhu.
That was usefull..
0 Kudos
sandeep_madhu14
Level 6

hi anitha,

Do You want inforamtion regarding the how to check default Browser in end user System... I got the solution for it.. do you want that solution also..
Thanks
Madhu.
0 Kudos
J_anitha
Level 8

Thanks Madhu.
When I access a file using LaunchAppAndWait, I get a file download confirmation dialog, which prompts me to save\open the file.
I dont want that dialog to come up..
My requirement is to copy a file from web to a local folder, and run it from there..all these shouldnt pop up any dialogs 😞
I tried CopyFile, but it fails to copy from web....
0 Kudos
J_anitha
Level 8

Hi Madhu,

Please post default browser checking code 🙂
0 Kudos
sandeep_madhu14
Level 6

Hi,
you are saying that u want to copy file from web,can u please specify the website name and type of file which u want to download...
thanks
madhu
0 Kudos
J_anitha
Level 8

Thanks for your response.

We wanted to download certain installables from our company website itself.
File type would be .exe/.msi
It should either start installing from the web, or copy it to a local folder and install later.
But we dont need the File Download Security Warning message popping up...
0 Kudos
sandeep_madhu14
Level 6

hi,
This is the code for checking defaultbrowser on end user system.....

#include "ifx.h"


prototype INT getExtCmdLine( STRING , BYREF STRING );

STRING svExtensiom,svCommandLine,szCommand,szcmdLine;






function OnFirstUIBefore()
NUMBER nResult, nSetupType, nvSize, nUser;
STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
STRING szLicenseFile;
BOOL bCustom, bIgnore1, bIgnore2;
begin



nSetupType = TYPICAL;

Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;

szTitle = "";
svName = "";
svCompany = "";

end;

program
//getExtCmdLine(".txt",svCommandLine);

getExtCmdLine(".html",svCommandLine);
//getExtCmdLine(".docx",svCommandLine);
//getExtCmdLine(".msi",svCommandLine);

//LaunchApp ( svCommandLine , "" );
LaunchApp(svCommandLine,"");
endprogram


function int getExtCmdLine(svFileExtension,svCmd)
NUMBER nvDummy,nvPos;
STRING svFileType,svCmdKey;
begin

RegDBSetDefaultRoot(HKEY_CLASSES_ROOT);
//chk to see the file extension

if(RegDBKeyExist(svFileExtension)=1) then
//retrieve the default value

RegDBGetKeyValueEx(svFileExtension,"",nvDummy,svFileType,nvDummy);
MessageBox(svFileType,INFORMATION);

//chk for default commandline

svCmdKey= svFileType + "\\shell\\open\\command";
if(RegDBKeyExist(svCmdKey) =1) then

RegDBGetKeyValueEx(svCmdKey,"",nvDummy,svCmd,nvDummy);
MessageBox(svCmd,INFORMATION);
nvPos = StrFind(svCmd,"%");
//nvPos = StrFindEx(svCmd,"%",nvDummy);


if ( nvPos > 0 ) then
svCmd[nvPos] = NULL;

MessageBox (svCmd,INFORMATION);
elseif( nvPos < 0 ) then
MessageBox ( svFileType + " does not have an applicationassociated with it." , WARNING );
//svCmd = "";

else
MessageBox ( svFileExtension + " file extension is not registered.", WARNING );

endif;
//return svCmd;

endif;
endif;
end;
0 Kudos
J_anitha
Level 8

We wanted to download certain installables from our company website itself.
File type would be .exe/.msi
It should either start installing from the web, or copy it to a local folder and install later.
But we dont need the File Download Security Warning message popping up...
0 Kudos
sandeep_madhu14
Level 6

Hi,

you said that you want to copy that downloaded file to local folder then we can do it easily.
1)In my code i have given www.google.com as an example.In that place u give your company website.
2)Next step then your able to visit that site.
3)while downloading it will ask save option then u save that file to local file which you want..


have you understand the code which i send regarding the chking the default browser....
0 Kudos
J_anitha
Level 8

I dont want that dialog box to be displayed for saving the file. I want to do that without any user intervention.
0 Kudos
sandeep_madhu14
Level 6

hi,

In general if you want to download any file or any image it will ask save option .We can not supress that dialogbox ...

could you please say me in clear way so that i can work on it..


here u r saying that u want to store it in to the local folder....then how can you save downloaded file directly to that folder without user interaction...
thanks
madhu
0 Kudos
J_anitha
Level 8

Our installer has to install other software which are available on net.
For this I should either copy the installable from net to local PC and run it, or directly run it from web..
In either way, I need to do that without user intervention.
I had read in some forum that XCopyFile can do the copy for me, but it failed to do so..
Now I am checking for an alternate way of doing it.
0 Kudos
J_anitha
Level 8

XCopyFile works, but it takes lot of time to copy file to local disk!!!
Any idea towards this is welcome..
0 Kudos
sandeep_madhu14
Level 6

hi
yes i too have seen that through xcopy we can get it ..k i got another solution i am working on it ..if i get solution i will report you ..
thanks
madhu
0 Kudos
sandeep_madhu14
Level 6

hi anitha,
did u get the solution for it.. using xcopy..
thanks
madhu
0 Kudos
J_anitha
Level 8

using XCopy, it does work, but it's too slow:(
for 2MB, its more than a min! Tried installing directly from web, without copying to local disk..no luck!! that too s very slow.
We can't afford to use any of these, as our applications are around 60MB each.
Got to try some other options now..

Thanks for your help, Madhu.

Rgds,
Anitha
0 Kudos