PDA

View Full Version : Web download, and Install


Sheritlw
03-20-2007, 02:33 AM
Hi, Well this is the code I came up with, but it's not downloading from my web. This is in the On Next event of the last form (Ready to Install).
What am I doing wrong? Thanks for your help


local bdbInstall = true;
local bKeyExists = false;
local bsql = false;
local bresult = false;
local bdb = false;
local bsuccess = false;

--sdbInstall = SetupData.GetPackageProperties("EZDB");
--bdbInstall = Database.Install;

if bdbInstall then
bKeyExists = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Microsoft SQL Server\\SQLEXPRESS");

if bKeyExists == false then
-- better check internet connection
result = HTTP.TestConnection("http://www.scheduleez-pro.com/", 20, 80, nil, nil);

if result then

--download sql express and database from our web
--SessionVar.Expand("%TempFolder%\\setup.exe"),
--"SQLDB.exe server:
bsql = HTTP.Download("http://www.scheduleez-pro.com/downloads/SQLEXPR32.exe",SessionVar.Expand("%TempFolder%\\SQLEXPR32.exe"), MODE_BINARY, 20, 80, nil, nil, nil);
result = Dialog.Message("dOWNLOADING", "ScheduleEZ was not able to download SQL Express. ", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
if bsql then
bsql = File.Run(SessionVar.Expand("%TempFolder%\\SQLEXPR32.exe"), "", "", SW_SHOWNORMAL, true);
if bsql then -- we have installed sql server 'now lets download then db
bdb = HTTP.Download("http://www.scheduleez-pro.com/downloads/EZDB.exe",SessionVar.Expand("%TempFolder%\\EZDB.exe"), MODE_BINARY, 30, 80, nil, nil, nil);
if bdb then -- we have successfuly downloaded the db lets execute it
bsql = File.Run(SessionVar.Expand("%TempFolder%\\EZDB.exe"), "EZDB.exe server:.\SQLEXPRESS /database:ScheduleEZ /username:ezuser /password:ezez /quiet", "", SW_SHOWNORMAL, true);
if bsql then
bsuccess = true;
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end

else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end
else --- it is installed so lets just do db
bdb = HTTP.Download("http://www.scheduleez-pro.com/downloads/EZDB.exe",SessionVar.Expand("%TempFolder%\\EZDB.exe"), MODE_BINARY, 30, 80, nil, nil, nil);
if bdb then -- we have successfuly downloaded the db lets execute it
bsql = File.Run(SessionVar.Expand("%TempFolder%\\EZDB.exe"), "EZDB.exe server:.\SQLEXPRESS /database:ScheduleEZ /username:ezuser /password:ezez /quiet", "", SW_SHOWNORMAL, true);
if bsql then
bsuccess = true;
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
result = Dialog.Message("Notice", "ScheduleEZ was not able to download SQL Express. ", MB_ABORTRETRYIGNORE, MB_ICONSTOP, MB_DEFBUTTON1);
end

end


end

if bsuccess then
Screen.Next();
end
-- advance to the next screen

JXBURNS
03-20-2007, 02:54 AM
I find this difficult to read due to no indentations on the if/end logic lines. If you wrap CODE tags (the # option) around the code then will display correctly.

There are two things I note.

a) The File.Run statement uses an argument parameter. I have seen from experience that sometimes this will not work so you should try moving contents of second parameter into first, and leave second parameter blank. Also use a working folder even if it does not obviously require one.

For example

bsql = File.Run(SessionVar.Expand("%TempFolder%\\EZDB.exe ") .. "EZDB.exe server:.\SQLEXPRESS /database:ScheduleEZ /username:ezuser /password:ezez /quiet", "", SessionVar.Expand("%TempFolder%"), SW_SHOWNORMAL, true);

b) The second is you have syntax errors in your code. 10 lines from bottom you have SessionVar.Expand("%TempFolder%\\EZDB.ex e"). Note the space in EZDB.ex e.

John

Sheritlw
03-21-2007, 01:03 AM
Hi, I pasted formated code into the message box, but it didn't hold the formatting. I apologize, but I tried.
First, I haven't even reached the run part. I get the error when first trying to download, so maybe need to start off with the code line...
HTTP.download. then go from there.

Thanks

JXBURNS
03-21-2007, 02:56 AM
Is there really a space in your download line in SQ LEXPR32.exe ?

That would cause the download to fail.

John

pww
03-21-2007, 10:36 AM
I get the error when first trying to download


What error? In the IDE, or runtime? Could it be something external, like a firewall blocking the installer?

As for the spaces, it's the forum software that puts them in some potentially 'dangerous' strings like 'sql' or 'exe'. If you put code tags around the pasted code (click # icon) , it will not be modified.

Sheritlw
03-21-2007, 01:48 PM
I am testing the setup on a virtual machine. I went to the path through IE and no problems accessing it. So there must be something wrong in the code.
I think maybe we should start with getting it to download and then test the rest.
Code to the point of download is. I will try to reformat after pasting

local bdbInstall = true;
local bKeyExists = false;
local bsql = false;
local bresult = false;
local bdb = false;
local bsuccess = false;

--sdbInstall = SetupData.GetPackageProperties("EZDB");
--bdbInstall = Database.Install;

if bdbInstall then
bKeyExists = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Microsoft SQL Server\\SQLEXPRESS");

if bKeyExists == false then
-- better check internet connection
result = HTTP.TestConnection("http://www.scheduleez- pro.com/", 20, 80, nil, nil);

if result then

bsql = HTTP.Download("http://www.scheduleez-pro.com/downloads/SQLEXPR32.exe",SessionVar.Expand("%TempFolder%\\SQLEXPR32.exe"), MODE_BINARY, 20, 80, nil, nil, nil);

JXBURNS
03-21-2007, 03:34 PM
I created a new project, removed all before and during screens, put this in my ON POST INSTALL actions, compiled and run. Had no problem downloading the SQLEXP32 file from your server.

local bKeyExists = false;

-- Commented out as my system does have SQLExpress installed and registry was reporting true - I want to forced the download.
--bKeyExists = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Microsoft SQL Server\\SQLEXPRESS");

if bKeyExists == false then
-- better check internet connection
result = HTTP.TestConnection("http://www.scheduleez-pro.com/", 20, 80, nil, nil);
if result then
bsql = HTTP.Download("http://www.scheduleez-pro.com/downloads/SQLEXPR32.exe",SessionVar.Expand("%TempFolder%\\SQLEXPR32.exe"), MODE_BINARY, 20, 80, nil, nil, nil);
end
end
Note that I used the # option (second icon from right above message area when creating message) after I had highlighted the code I wanted to include in the code area. This retains the formatting as you can see.

If this does not work for you then there must be a firewall problem somewhere.

Rgds John