I have created an installer for a classic asp website.
I can add the application to the IIS and set Application Pool, Friendly Name and Allow Scripts.
I would like to set "Enable Parent Paths" too.
Any idea? Is there any EnableParentPaths = true?
Here is somw code I used to add the website to IIS in case is needed:
if (IISOptionsPage.Values[1] <> '') then begin
IISDefAppPool := IISOptionsPage.Values[1];
end else begin
IISDefAppPool := ExpandConstant('{#IISDefaultAppPool}');
end;
{ Create the main IIS COM Automation object }
try
IIS := CreateOleObject('IISNamespace');
except
RaiseException('IIS is not installed?.'#13#13'(Error: ''' + GetExceptionMessage );
end;
{ Connect to the IIS server }
WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
WebAppName := ExtractLastDir(ExpandConstant('{app}'));
{ (Re)create a virtual dir }
try
WebRoot.Delete('IIsWebVirtualDir', WebAppName);
WebRoot.SetInfo();
except
end;
VDir := WebRoot.Create('IIsWebVirtualDir', WebAppName);
VDir.AccessRead := True;
VDir.AccessScript := True;
VDir.AppFriendlyName := WebAppName;
VDir.Path := ExpandConstant('{app}');
try
VDir.AppPoolId := IISDefAppPool;
except
MsgBox('AppPool not set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
try
VDir.AppCreate(True);
except
MsgBox('App not created.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
try
VDir.SetInfo();
except
MsgBox('Info no set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
My guess is that you're looking for the AspEnableParentPaths property of the IIsWebVirtualDir object. Try to extend your script with the following line:
VDir.AspEnableParentPaths := True;
Related
With Inno Download Plugin I had a code that registers a list of files to download and adds the list to "Ready" page memo at the same time:
Building memo text for Inno Download Plugin
I have modified the code to work with Inno Setup 6.1.1 download page, instead of IDP:
procedure AddFileForDownload(Url, FileName: string);
begin
DownloadPage.Add(Url, FileName, '');
FilesToDownload := FilesToDownload + ' ' + ExtractFileName(FileName) + #13#10;
Log('File to download: ' + Url);
end;
Then I adjusted NextButtonClick like this:
function NextButtonClick(CurPageID: integer): boolean;
begin
Result := True;
if (CurPageID = wpReady) then
begin
DownloadPage.Clear;
if (dotNetNeeded) then begin
{ We need to download the 4.6.2 setup from the Microsoft Website }
dotNetRedistPath := ExpandConstant('{tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
AddFileForDownload(dotnetRedistURL, 'NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
end;
if (bVcRedist64BitNeeded) then
begin
{ We need to download the 64 Bit VC Redistributable from the Microsoft Website }
vcRedist64BitPath := ExpandConstant('{tmp}\vc_redist.x64.exe');
AddFileForDownload(vcRedist64BitURL, 'vc_redist.x64.exe');
end;
if (bVcRedist32BitNeeded) then
begin
{ We need to download the 32 Bit VC Redistributable from the Microsoft Website }
vcRedist32BitPath := ExpandConstant('{tmp}\vc_redist.x86.exe');
AddFileForDownload(vcRedist32BitURL, 'vc_redist.x86.exe');
end;
if (WizardIsTaskSelected('downloadhelp')) then
AddFileForDownload('{#HelpDocSetupURL}', 'HelpDocSetup.exe');
DownloadPage.Show;
try
try
DownloadPage.Download;
Result := True;
except
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end;
end;
I ran the installer, and checked the wizard option to download the help documentation, and yet the Ready page displays only:
The Download section is not being added. How can that be? When I click Next it does continue to the next page to download the file.
I added some extra logging for FilesToDownload and it is interesting:
2020-11-01 11:44:22.409 UpdateReadyMemo FileToDownload:
2020-11-01 11:44:25.671 File to download: https://www.publictalksoftware.co.uk/downloads/MSAHelpDocumentationSetup.exe
2020-11-01 11:44:25.671 FileToDownload: HelpDocSetup.exe
The UpdateReadyMemo method is being called before we populate the variable. Confused!
I got confused a bit initially. Because the issue is obvious. Your code executes when you click "Install" button on the "Ready" page. So obviously only after the "Ready" page shows.
You have to call the AddFileForDownload earlier. Maybe to NextButtonClick(wpSelectTasks).
function NextButtonClick(CurPageID: integer): boolean;
begin
Result := True;
if (CurPageID = wpSelectTasks) then
begin
DownloadPage.Clear;
if (dotNetNeeded) then
begin
// We need to download the 4.6.2 setup from the Microsoft Website
dotNetRedistPath :=
ExpandConstant('{tmp}\NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
AddFileForDownload(
dotnetRedistURL, 'NDP451-KB2858728-x86-x64-AllOS-ENU.exe');
end;
if (bVcRedist64BitNeeded) then
begin
// We need to download the 64 Bit VC Redistributable
// from the Microsoft Website
vcRedist64BitPath := ExpandConstant('{tmp}\vc_redist.x64.exe');
AddFileForDownload(vcRedist64BitURL, 'vc_redist.x64.exe');
end;
if (bVcRedist32BitNeeded) then
begin
// We need to download the 32 Bit VC Redistributable
// from the Microsoft Website
vcRedist32BitPath := ExpandConstant('{tmp}\vc_redist.x86.exe');
AddFileForDownload(vcRedist32BitURL, 'vc_redist.x86.exe');
end;
if (WizardIsTaskSelected('downloadhelp')) then
AddFileForDownload('{#HelpDocSetupURL}', 'HelpDocSetup.exe');
end
else
if (CurPageID = wpReady) then
begin
DownloadPage.Show;
try
try
DownloadPage.Download;
Result := True;
except
SuppressibleMsgBox(
AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end;
end;
(untested)
I'm using Inno Setup to create my own installer. When user uninstall app I want delete some folder.
So I use CurUninstallStepChanged event to delete folder and show "progress bar" with npbstMarquee style (based on Inno Setup: How to handle progress bar on [UninstallDelete] section?).
Here is the code:
procedure DeleteFolder();
var
FindRec: TFindRec;
fullPath: string;
tmpMsg: string;
StatusText: string;
deletePath: string;
begin
{ find all and delete }
UninstallProgressForm.ProgressBar.Style := npbstMarquee;
StatusText := UninstallProgressForm.StatusLabel.Caption;
UninstallProgressForm.StatusLabel.WordWrap := True;
UninstallProgressForm.StatusLabel.AutoSize := True;
fullPath := 'C:\ProgramData\TestPath';
if FindFirst(ExpandConstant(fullPath + '\*'), FindRec) then
try
repeat
if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and
(FindRec.Name <> '.') and (FindRec.Name <> '..') then begin
deletePath := AddBackslash(fullPath) + FindRec.Name;
tmpMsg := 'Deleting...' + #13#10 + deletePath;
UninstallProgressForm.StatusLabel.Caption := tmpMsg;
DelTree(deletePath, True, True, True);
end;
until
not FindNext(FindRec);
finally
UninstallProgressForm.StatusLabel.Caption := StatusText;
FindClose(FindRec);
end;
UninstallProgressForm.ProgressBar.Style := npbstNormal;
end;
{ Uninstall event }
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
usUninstall:
begin
DeleteFolder();
end;
end;
end;
If I using debug each line, I can see progress bar running. But when I using unins000.exe then only Caption can show, progress bar is not showing.
How can I fix it?
You have to pump the message queue to display/animate the progress bar.
Inno Setup: How to modify long running script so it will not freeze GUI?
Particularly, you can use the AppProcessMessage function from:
My SQL server discovery on LAN by listening port (Inno Setup)
Though with use of DelTree, the interval between calls to AppProcessMessage will be too big to animate the progress bar smoothly. You would have to implement a recursive delete explicitly to allow pumping the queue frequently enough.
I am looking for a code for Inno Setup, that I can use to make my setup verify my permission to install the program. This code must check a text file on a web server.
If the file has the value "False", the setup has to cancel an installation and save the value in a registry file to cancel it always when Internet connection is not available.
If the file has the value "True", the setup will continue to install, and it will delete the registry file value if it exists.
If there is no Internet and the registry value does not exist the setup will continue to install.
Use InitializeSetup event function to trigger your check using HTTP request.
[Code]
const
SubkeyName = 'Software\My Program';
AllowInstallationValue = 'Allow Installation';
function IsInstallationAllowed: Boolean;
var
Url: string;
WinHttpReq: Variant;
S: string;
ResultDWord: Cardinal;
begin
try
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
Url := 'https://www.example.com/can_install.txt';
WinHttpReq.Open('GET', Url, False);
WinHttpReq.Send('');
if WinHttpReq.Status <> 200 then
begin
RaiseException(
'HTTP Error: ' + IntToStr(WinHttpReq.Status) + ' ' + WinHttpReq.StatusText);
end
else
begin
S := Trim(WinHttpReq.ResponseText);
Log('HTTP Response: ' + S);
Result := (CompareText(S, 'true') = 0);
if RegWriteDWordValue(
HKLM, SubkeyName, AllowInstallationValue, Integer(Result)) then
Log('Cached response to registry')
else
Log('Error caching response to registry');
end;
except
Log('Error: ' + GetExceptionMessage);
if RegQueryDWordValue(HKLM, SubkeyName, AllowInstallationValue, ResultDWord) then
begin
Log('Online check failed, using cached result');
Result := (ResultDWord <> 0);
end
else
begin
Log('Online check failed, no cached result, allowing installation by default');
Result := True;
end;
end;
if Result then Log('Can install')
else Log('Cannot install');
end;
function InitializeSetup(): Boolean;
begin
Result := True;
if not IsInstallationAllowed then
begin
MsgBox('You cannot install this', mbError, MB_OK);
Result := False;
end;
end;
I have created an installer for a classic asp website.
I managed to install website in my "Root" (Default Web Site) ok.
But I would like to install website under "Sites" but not in "Root" for exmaple in an existing "Demo" site.
Any idea?
I think the key is in line:
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
Some code I used to add the website to IIS "Root" in case is needed:
if (IISOptionsPage.Values[1] <> '') then begin
IISDefAppPool := IISOptionsPage.Values[1];
end else begin
IISDefAppPool := ExpandConstant('{#IISDefaultAppPool}');
end;
{ Create the main IIS COM Automation object }
try
IIS := CreateOleObject('IISNamespace');
except
RaiseException('IIS is not installed?.'#13#13'(Error: ''' + GetExceptionMessage );
end;
{ Connect to the IIS server }
WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
WebAppName := ExtractLastDir(ExpandConstant('{app}'));
{ (Re)create a virtual dir }
try
WebRoot.Delete('IIsWebVirtualDir', WebAppName);
WebRoot.SetInfo();
except
end;
VDir := WebRoot.Create('IIsWebVirtualDir', WebAppName);
VDir.AccessRead := True;
VDir.AccessScript := True;
VDir.AppFriendlyName := WebAppName;
VDir.AspEnableParentPaths := True;
VDir.Path := ExpandConstant('{app}');
try
VDir.AppPoolId := IISDefAppPool;
except
MsgBox('AppPool not set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
try
VDir.AppCreate(True);
except
MsgBox('App not created.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
try
VDir.SetInfo();
except
MsgBox('Info no set.'#13#13'(Error: ''' + GetExceptionMessage, mbInformation, mb_Ok);
end;
I am not expert on COM automation objects but what about passing 'Sites\' as parameter in:
VDir := WebRoot.Create('IIsWebVirtualDir', 'Sites\' + WebAppName);
Is it possible to create subdirs in WebRoot.Create? I think it is worth the try :)
Or the second idea, passing 'Sites' in:
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Sites');
I have just started using inno setup, and it seems to work well. However, when I run the installer with the app already installed it reinstalls. I would like to give the user to uninstall. Is this possible, and if so, how can it be done?
To be specific, I have written a game for a homework assignment. I made an installer using inno setup. The app installs fine and can be uninstalled using the control panel, but my professor would like to be able to uninstall the application by re-running the installer and choosing an uninstall option. This will save him time since he has about 50 of these assignments to mark.
Thanks,
Gerry
The next script will make the following options form when the application is already installed on the target system when the setup is started:
When the user clicks Repair button, the setup is normally started. When user clicks the Uninstall button, the previously installed application is uninstalled. When user closes that form, nothing happens.
Here is the script (don't forget to specify, ideally some unique, value for the AppId setup directive in your script):
[Setup]
AppName=My Program
AppVersion=1.5
AppId=1C9FAC66-219F-445B-8863-20DEAF8BB5CC
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
[CustomMessages]
OptionsFormCaption=Setup options...
RepairButtonCaption=Repair
UninstallButtonCaption=Uninstall
[Code]
const
mrRepair = 100;
mrUninstall = 101;
function ShowOptionsForm: TModalResult;
var
OptionsForm: TSetupForm;
RepairButton: TNewButton;
UninstallButton: TNewButton;
begin
Result := mrNone;
OptionsForm := CreateCustomForm;
try
OptionsForm.Width := 220;
OptionsForm.Caption := ExpandConstant('{cm:OptionsFormCaption}');
OptionsForm.Position := poScreenCenter;
RepairButton := TNewButton.Create(OptionsForm);
RepairButton.Parent := OptionsForm;
RepairButton.Left := 8;
RepairButton.Top := 8;
RepairButton.Width := OptionsForm.ClientWidth - 16;
RepairButton.Caption := ExpandConstant('{cm:RepairButtonCaption}');
RepairButton.ModalResult := mrRepair;
UninstallButton := TNewButton.Create(OptionsForm);
UninstallButton.Parent := OptionsForm;
UninstallButton.Left := 8;
UninstallButton.Top := RepairButton.Top + RepairButton.Height + 8;
UninstallButton.Width := OptionsForm.ClientWidth - 16;
UninstallButton.Caption := ExpandConstant('{cm:UninstallButtonCaption}');
UninstallButton.ModalResult := mrUninstall;
OptionsForm.ClientHeight := RepairButton.Height + UninstallButton.Height + 24;
Result := OptionsForm.ShowModal;
finally
OptionsForm.Free;
end;
end;
function GetUninstallerPath: string;
var
RegKey: string;
begin
Result := '';
RegKey := Format('%s\%s_is1', ['Software\Microsoft\Windows\CurrentVersion\Uninstall',
'{#emit SetupSetting("AppId")}']);
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'UninstallString', Result) then
RegQueryStringValue(HKEY_CURRENT_USER, RegKey, 'UninstallString', Result);
end;
function InitializeSetup: Boolean;
var
UninstPath: string;
ResultCode: Integer;
begin
Result := True;
UninstPath := RemoveQuotes(GetUninstallerPath);
if UninstPath <> '' then
begin
case ShowOptionsForm of
mrRepair: Result := True;
mrUninstall:
begin
Result := False;
if not Exec(UninstPath, '', '', SW_SHOW, ewNoWait, ResultCode) then
MsgBox(FmtMessage(SetupMessage(msgUninstallOpenError), [UninstPath]), mbError, MB_OK);
end;
else
Result := False;
end;
end;
end;
For some reason your code
RegKey := Format('%s\%s_is1', ['Software\Microsoft\Windows\CurrentVersion\Uninstall',
'{#emit SetupSetting("AppId")}']);
returned an extra { to the _is1 value. I didn't had the time to check why or where i was wrong in my implementation,
all i confirm is that my installer works with the
RegKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
alternate.
Hope it helps.
Thank you for the code sample.
When using Inno Setup, there's no reason to uninstall a previous version unless that version was installed by a different installer program. Otherwise upgrades are handled automatically.
Your answer is here :
InnoSetup: How to automatically uninstall previous installed version? previous-installed-version