Inno Setup doesn't create a scheduled task - inno-setup

My installer should install a Windows scheduled task for the application. The task definition is provided in an XML file. Installing the XML task file interactively works fine. But the installer doesn't install the task. Since I don't see its output, I don't know whether an error message is displayed. Windows event log doesn't contain anything.
The Inno Setup task "InstallAutostart" is checked so this should be executed. The files are copied to the installation directory.
Here's the script:
[Run]
Filename: "schtasks.exe"; Parameters: "/create /tn TClockAutostart /xml ""{app}\StartTClock.xml"""; WorkingDir: "{app}"; Description: "Install task for safe automatic start"; Tasks: InstallAutostart; Check: Not IsWin64
Filename: "schtasks.exe"; Parameters: "/create /tn TClockAutostart /xml ""{app}\StartTClock64.xml"""; WorkingDir: "{app}"; Description: "Install task for safe automatic start"; Tasks: InstallAutostart; Check: IsWin64
What's wrong here? How can I debug this?

Related

Inno Setup: Disable desktop icon and autostart entry via command line parameter

I'm creating an desktop icon and an autostart entry with an Inno Setup script like this:
[Icons]
Name: "{commonstartup}\abc"; Filename: "{app}\xyz.exe"; WorkingDir: "{app}"; Flags: createonlyiffileexists; Tasks: StartMenuEntry
Name: "{commondesktop}\abc"; Filename: "{app}\xyz.exe"; WorkingDir: "{app}"; IconIndex: 0; Tasks: desktopicon
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: "StartMenuEntry"; Description: "{cm:AutoStartProgram}"; GroupDescription: "{cm:AutoStartProgramGroupDescription}"
Some users want to run my setup.exe from the command line. They want to add a parameter for silent installation /VERYSILENT and a parameter for disabling the desktop icon and the autostart entry.
Is that possible with a command line parameter? If not: What else is possible to do that? Thanks!
Use /TASKS or better /MERGETASKS command-line switches to alter the default task selection.
Particularly, to disable particular task, use /MERGETASK=!taskname:
mysetup.exe /VERYSILENT /MERGETASKS=!desktopicon,!StartMenuEntry
Related question: Command line switch to prevent Inno Setup installer from creating desktop Icon

Create desktop link Icon after the Run section of Inno Setup

Overview
My install process involves placing over 2GB of data on a disk. So I use Inno Setup, but I run 7ZIP to actually extract/install the files.
Issue
The issue I have is that it seems the desktop icon is being created before the [Run] section, so there is no icon to set the the desktop link. Is there a way around this? (I have tried both {src} and {app} as the folder to find the icon.)
CODE
[Run]
Filename: "{pf64}\7-zip\7zG.exe"; Parameters: "x ""{src}\GL.7z"" -o""{app}\"" * -r -aoa"; \
Flags: runascurrentuser
[Icons]
Name: "{group}\EGPL Watson Uninstall"; Filename: "{uninstallexe}"; WorkingDir: "{app}"
Name: "{commondesktop}\DashBoard"; \
Filename: "{app}\dashboard\node_modules\electron\dist\electron.exe"; \
WorkingDir: "{app}\dashboard"; IconFilename: "{src}\dashboard\build\configure.ico"; \
Parameters: "main.js"; AfterInstall: SetElevationBit('{commondesktop}\DashBoard.lnk')
A quick and dirty solution is to set ChangesAssociations:
[Setup]
ChangesAssociations=yes
It makes Windows Explorer refresh all icons after the installer finishes.
A clean solution is to create the icon only after the [Run] section using CreateShellLink:
[Run]
Filename: "{pf64}\7-zip\7zG.exe"; \
Parameters: "x ""{src}\GL.7z"" -o""{app}\"" * -r -aoa"; \
Flags: runascurrentuser; AfterInstall: CreateIcon
[Code]
procedure CreateIcon;
var
IconFileName: string;
begin
IconFileName := ExpandConstant('{commondesktop}\DashBoard.lnk');
CreateShellLink(
IconFileName, '',
ExpandConstant('{app}\dashboard\node_modules\electron\dist\electron.exe'),
'main.js', ExpandConstant('{app}\dashboard'),
ExpandContant('{app}\dashboard\build\configure.ico'), 0, SW_SHOWNORMAL);
SetElevationBit(IconFileName);
end;

Inno Setup: Check if OpenDCL is installed, otherwise install it

I want that my script checks, if OpenDCL is installed. If it isn't, it should install it.
This is the code:
Source:
[Setup]
AppId={{7EED6191-0CC5-4D95-B28B-D5AB92F09685}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=C:\Cobiax\{#MyAppName}
DisableDirPage=yes
UsePreviousAppDir=yes
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultGroupName={#MyAppName}
InfoAfterFile=C:\Cobiax\Sorgenti\Cobiax Plan\info.txt
OutputBaseFilename=CobiaxPlan v1.0
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
[UninstallDelete]
Type: filesandordirs; Name: "C:\Cobiax\"
[Files]
Source: C:\Cobiax\Sorgenti\OpenDCL.Runtime.8.0.1.0.msi; \
DestDir: C:\Cobiax\Cobiax Plan\; Flags: deleteafterinstall
[Run]
Filename: msiexec.exe; Parameters: /i {app}\OpenDCL.Runtime.8.0.1.0.msi
[UninstallRun]
Filename: msiexec.exe; Parameters: /x {app}\OpenDCL.Runtime.8.0.1.0.msi
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Thank you very much, Dennis
Ps. Is it possible to hide that splash screen?
You have different paths to OpenDCL.Runtime.8.0.1.0.msi in [Files] and [Run] section. You install the package to a fixed path C:\Cobiax\Cobiax Plan, while you run it from a user-defined installation path {app}. As the file is temporary, you probably want to install and run it from {tmp}.
In any case, both paths probably contain a space (Cobiax Plan or Program Files). So you run
msiexec.exe /i C:\Program Files\MyAppName\OpenDCL.Runtime.8.0.1.0.msi
That's wrong. That's why you get the msiexec usage screen.
If the path contains a space, it needs to be enclosed to quotes:
msiexec.exe /i "C:\Program Files\MyAppName\OpenDCL.Runtime.8.0.1.0.msi"
The correct code would be:
[Files]
Source: C:\Cobiax\Sorgenti\OpenDCL.Runtime.8.0.1.0.msi; DestDir: {tmp}; \
Flags: deleteafterinstall
[Run]
Filename: msiexec.exe; Parameters: "/i ""{tmp}\OpenDCL.Runtime.8.0.1.0.msi"""

Error: Missing closing quote on parameter "Name"

At compile time, Inno keeps saying there was an error:
Line: 81
Error: Missing closing quote on parameter "Name"
but I don't see anything wrong. It points to the line just below [icons]
[Files]
Source: "{#SOURCEDIR}\Debug\myapplication.exe"; DestDir: {app}; Flags: ignoreversion
Source: "{#SOURCEDIR}\Debug\aDllFile.dll"; DestDir: {app}; Flags: ignoreversion
Source: "{#SOURCEDIR}\Debug\another.aDllFile.dll"; DestDir: {app}; Flags: ignoreversion
Source: "{#SOURCEDIR}\Debug\and.another.aDllFile.dll"; DestDir: {app}; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#APPTITLE}"; Filename: "{app}\{#APPEXENAME}"
Name: "{group}\{cm:ProgramOnTheWeb,{#APPTITLE}}"; Filename: "{#APPURL}"
Name: "{group}\{cm:UninstallProgram,{#APPTITLE}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#APPTITLE}"; Filename: "{app}\{#APPEXENAME}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#APPTITLE}"; Filename: "{app}\{#APPEXENAME}"; Tasks: quicklaunchicon
Name: "{userstartup}\{#APPTITLE}"; Filename: "{app}\{#APPEXENAME}"; IconFilename: "{app}\{#APPEXENAME}";
[Run]
;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, ""&"", ""&&"")}}"; Flags: nowait RunHidden SkipIfDoesntExist; Parameters: exit; WorkingDir: {app};
Filename: {app}\{#APPEXENAME}; Description: "{cm:LaunchProgram,{#StringChange(APPNAME, "noupdate", "&&")}}"; Flags: nowait postinstall skipifsilent
[Messages]
WelcomeLabel1=Welcome to the Setup Wizard for%n[name]
WelcomeLabel2=Salve! This application will install [name/ver] on your computer. You do not need administrator rights to do this.%n%nIf you would close your other applications before continuing, it would be mighty nice of you.
ExitSetupMessage=Hey! I'm not finished installing!%n If you exit now, the program will not be installed.%n%nHowever, you can always run the Setup again some other time if you wish to complete the installation.%n%nDo you still want to exit?
InfoBeforeLabel=Just a few little notes about {#APPTITLE}...
InfoBeforeClickLabel=When you are ready to continue the Installation, just click Next.
SelectTasksDesc=Just a few little tidbits, if you like them...
[note]
I can't believe this question was viewed 1003 times and noone gave me a vote!
Okay, I figured it out. One of my definitions was failing. It was supposed to extract the file_description from the target executable's resource.
#define APPTITLE GetStringFileInfo("C:\sourcepath\myapplication.exe", FILE_DESCRIPTION)
There was a ' in the File Description! And that caused Inno to offest all of its quotation marks.
Here is what Dee Earley at the Inno forum told me:
Why should it escape it? It doesn't know what it needs to escape it for, it's "just a string". You should escape it for it's output when needed using StringChange() or just quoting it properly. '

Run application after successful install

How to make check box that allow user to run application after installation?
There you go:
under [Run]:
Filename: {app}\{cm:AppName}.exe; Description: {cm:LaunchProgram,{cm:AppName}}; Flags: nowait postinstall skipifsilent
under [CustomMessages]:
AppName=mySoftwaresNiceName
LaunchProgram=Start mySoftware after finishing installation
Check the postinstall flag in the [Run] section, see the documentation at https://jrsoftware.org/ishelp/topic_runsection.htm#postinstall
Add Filename to Run Section with Flag postinstall.
Example for Copy&Paste:
[Run]
// User selected... these files are shown for launch after everything is done
Filename: {app}\README.TXT; Description: View the README file; Flags: postinstall shellexec skipifsilent
Filename: {app}\APP.EXE; Description: Run Application; Flags: postinstall nowait skipifsilent unchecked
To make the checkbox, create a task:
[Tasks]
Name: StartAfterInstall; Description: Run application after install
and bind it to "run" action:
[Run]
Filename: {app}\{#exe}; Flags: shellexec skipifsilent nowait; Tasks: StartAfterInstall
where {#exe} is the name of exe-file

Resources