2

I'm getting an "Access is denied" error right out of the box.

Here's my .iss file:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "MyApp"
#define MyAppVersion "1.5"
#define MyAppPublisher "InteXX"
#define MyAppURL "https://www.intexx.com/"
#define MyAppExeName "MyApp.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{2F651F6A-6F25-4B73-BC69-C2DC1E04420F}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
CreateAppDir=no
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename=MyApp
SetupIconFile=D:\Dev\Projects\Testing\MyApp\MyApp\Icon.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "D:\Dev\Projects\Testing\MyApp\Config\bin\Debug\Config.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Work\AppData\Local\InteXX\MyApp\Releases\Setup.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Run]
Filename: "{tmp}\MyApp\Config.exe"; Flags: waituntilterminated skipifdoesntexist
Filename: "{tmp}\MyApp\Setup.exe"; Flags: waituntilterminated skipifdoesntexist

...and here's the error message:

Oops!

There's this Q&A, which discusses the same error, but the scenario there is a bit different from mine. OP is attempting to have a file opened after his installation succeeds. I'm trying to get my installer to run in the first place.

I tried modifying the DestDir value slightly:

DestDir: "{app}\MyApp";

...and:

DestDir: "{app}\MyApp\";

However, these failed as well.

Some considerations:

  • Setup.exe is a Squirrel-generated setup file
  • Config.exe is a small stub executable that does nothing except set the SQUIRREL_TEMP environment variable to specify a custom install folder for MyApp
  • The only reason I'm using Inno at all is so that I can set the variable's value before Squirrel runs
  • I'm intentionally omitting any target directory in my .iss file, as Squirrel will use the value contained in the variable

Given the above, how should I modify my .iss file in order to get a successful installation?


Edit 1: Per Lex's suggestion in the comments, I made some changes to my .iss file:

[Files]
Source: "D:\Dev\Projects\Testing\MyApp\Config\bin\Debug\Config.exe"; DestDir: "{tmp}"; Flags: ignoreversion
Source: "D:\Dev\Projects\Testing\MyApp\MyApp\bin\Debug\Setup.exe"; DestDir: "{tmp}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Run]
Filename: "{tmp}\Config.exe"; Flags: waituntilterminated skipifdoesntexist; WorkingDir: {tmp}
Filename: "{tmp}\Setup.exe"; Flags: waituntilterminated skipifdoesntexist; WorkingDir: {tmp}

However, the problem persists.


Edit 2: Per Martin's request in the comments, here's a log file:

2020-07-11 11:36:03.621   Log opened. (Time zone: UTC-08:00)
2020-07-11 11:36:03.621   Setup version: Inno Setup version 6.0.5 (u)
2020-07-11 11:36:03.621   Original Setup EXE: D:\Dev\Projects\Testing\MyApp\MyApp\Output\MyApp.exe
2020-07-11 11:36:03.621   Setup command line: /SL5="$2E1D68,3097553,911872,D:\Dev\Projects\Testing\MyApp\MyApp\Output\MyApp.exe" 
2020-07-11 11:36:03.622   Windows version: 10.0.18363  (NT platform: Yes)
2020-07-11 11:36:03.622   64-bit Windows: Yes
2020-07-11 11:36:03.622   Processor architecture: x64
2020-07-11 11:36:03.622   User privileges: None
2020-07-11 11:36:03.625   Administrative install mode: No
2020-07-11 11:36:03.625   Install mode root key: HKEY_CURRENT_USER
2020-07-11 11:36:03.713   64-bit install mode: No
2020-07-11 11:36:03.719   Created temporary directory: C:\Users\Work\AppData\Local\Temp\is-1AIP0.tmp
2020-07-11 11:36:07.329   Found 2 files to register with RestartManager.
2020-07-11 11:36:07.329   Calling RestartManager's RmGetList.
2020-07-11 11:36:07.347   RmGetList finished successfully.
2020-07-11 11:36:07.348   RestartManager found no applications using one of our files.
2020-07-11 11:36:07.431   Starting the installation process.
2020-07-11 11:36:07.448   Directory for uninstall files: C:\WINDOWS
2020-07-11 11:36:07.448   Creating new uninstall log: C:\WINDOWS\unins000.dat
2020-07-11 11:36:07.448   Fatal exception during installation process (Exception):
                          CreateFile failed; code 5.
                          Access is denied.
2020-07-11 11:36:07.448   Exception message:
2020-07-11 11:36:07.448   Message box (OK):
                          CreateFile failed; code 5.
                          Access is denied.
2020-07-11 11:36:11.110   User chose OK.
2020-07-11 11:36:11.110   Message box (OK):
                          Setup was not completed.
                          
                          Please correct the problem and run Setup again.
2020-07-11 11:36:12.193   User chose OK.
2020-07-11 11:36:12.193   Rolling back changes.
2020-07-11 11:36:12.211   Starting the uninstallation process.
2020-07-11 11:36:12.211   Uninstallation process succeeded.
2020-07-11 11:36:13.712   Deinitializing Setup.
2020-07-11 11:36:13.783   Log closed.

I see where the problem is occurring now, but I'm still at a loss as to how to fix it. Clearly I need to put the uninstall file(s) somewhere other than C:\WINDOWS, but I'm yet unsure how to do this.

InteXX
  • 6,135
  • 6
  • 43
  • 80

1 Answers1

2

Your installer has CreateAppDir set to no. For that scenario, the documentation days:

If the uninstall feature is enabled when CreateAppDir is no, the uninstall data files are created in the system's Windows directory.


To solve the problem:

  • If you need the uninstaller, you have to store it somewhere. If your installer does not need Administrator privileges for anything (and hence you cannot write to system directory), you will have to create folder for the uninstaller files. So do not set the CreateAppDir to no. You can use DefaultDirName to customize the installation folder to use a folder, where you do not need the administrator privileges. The best practice is to use {autopf} constant.

    [Setup] 
    CreateAppDir=yes
    DefaultDirName={autopf}\My Program
    
  • Or you actually do not need the uninstaller. Then set Uninstallable to no.

    [Setup] 
    Uninstallable=no
    

    See also Use Inno Setup UI as a self-extractor only - No installation.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    I managed to nail down a bit of time to look at this. It works perfectly. I was starting to think I wasn't going to be able to use Inno, as I was getting duplicate installs—one from Inno, one from Squirrel—but this self-extractor approach seems to do the trick. It should get past overzealous malware checkers too. I'm still wrestling with setting a user-scoped environment variable prior to running the Squirrel setup, but that's a separate issue. Thank you for the tip. – InteXX Jul 14 '20 at 21:55