I am trying to make my Inno Setup program to run this command steam://
This command is used to open Steam program via the windows RUN tool.
I press WindowsKey+R and type the command steam:// and it opens the Steam program.
How can i make Inno Setup call this command?
I tried the following without success:
[Run]
Filename: "C:\Users\LUCAS\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"; Parameters: "steam://;
also tried that code bellow, and calling AfterInstall: RunOtherInstaller; on [Files] section, but it gives error on installation: %1 is not a valid Win32 application
[Code]
procedure RunOtherInstaller;
var
ResultCode: Integer;
begin
if not Exec(ExpandConstant('C:\Users\LUCAS\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk'), 'steam://', '', SW_SHOWNORMAL,
ewWaitUntilTerminated, ResultCode)
then
MsgBox('Error!!' + #13#10 +
SysErrorMessage(ResultCode), mbError, MB_OK);
end;
This link is a little strange... It actually points to nowhere when i try to follow it, but it is what calls the windows RUN tool.
I know i could call the Steam.exe from the default folder C:\Program Files (x86)\Steam\Steam.exe but i am trying to avoid problems with users who not have Steam on default folder... So i am trying to use this method running this "External Protocol" (i dont know if this is the right name for it): steam://
You can check registry for Steam location.
Part of my script for triggering installation:
[Code]
function SteamNotInstalled(): Boolean;
var
Path: String;
ErrorCode: Integer;
begin
Result := True;
if (RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam',
'InstallPath', Path)) and (FileExists(Path + '\Steam.exe')) then begin
ShellExec('', ExpandConstant('"' + Path + '\Steam.exe' + '"'), ' -install' + ExpandConstant(' "{src}"'),
'', SW_SHOW, ewNoWait, ErrorCode);
Result := False;
end;
end;
Or you can use shellexec in [Run] section
You can open the steam:// URL as any other URL.
procedure OpenUrl(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
Or use postinstall [Run] section entry:
[Run]
Filename: steam://xxx; Description: "Run game"; Flags: postinstall shellexec
See also
How to open a web site after uninstallation?
Inno Setup Compiler: How to auto start the default browser with given url?
Related
I have a setup for installing my application, and I need to run the application after successfully installing. I used postinstall to do this.
but it shows a checkbox and the user can uncheck it. I need to run the application without asking because of it kinda service which needs to runs at startup. if the user unchecked it he needs to restart the PC to launch.
So I can use the Filename: "{app}\myapp.exe" code without any flags in the Run section to launch the application but the problem is, It runs immediately after installing not after the finish button clicked.
The first issue is my application has an instruction window. it shows up at the launch so the setup window goes to the back. And the second issue is my application does not allow terminating unless uninstall becouse it need to run in the background. Setup waiting to process end to finish.
Is there any way to run the application after the finish button click in inno setup?
Simplifying the answer from Run Files and Programs according to custom checkboxes after clicking on Finish Button in Inno Setup, you can use a code like this:
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
Path, Msg: string;
begin
if CurPageID = wpFinished then
begin
Path := ExpandConstant('{app}\MyProg.exe');
if ExecAsOriginalUser(Path, '', '', SW_SHOW, ewNoWait, ResultCode) then
begin
Log('Executed MyProg');
end
else
begin
Msg := 'Error executing MyProg - ' + SysErrorMessage(ResultCode);
MsgBox(Msg, mbError, MB_OK);
end;
end;
Result := True;
end;
Replace ExecAsOriginalUser with Exec, if you want to run the program with elevated/Administrator privileges (if the installer uses them at all).
Add code section to your script like this:
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if CurStep = ssDone then
Exec(ExpandConstant('{app}\MyProg.exe'), '', '', SW_SHOW, ewNoWait, ResultCode);
end;
It will be triggered only on a success installation.
Use ExecAsOriginalUser instead of Exec if you don't want the exe run as admin.
My InnoSetup script opens a web page (with the user's default browser) at the end of the install process:
[Run]
Filename: http://example.com; Flags: shellexec
However, I'd like the web page to not be opened if the app already exists, i.e., if the user is installing a new version of the program. The web page should only be opened after the initial install. (I assume it's worth mentioning that the install includes an AppID, obviously, and enters values in the registry beside installing files.)
Thank you, as always -- Al C.
Yes, this is easy to do with scripting.
Just write
[Run]
Filename: "http://example.com"; Flags: shellexec; Check: NotAnUpdate
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
IsUpdate := FileExists(ExpandConstant('{app}\TheFileNameOfMyApp.exe'));
end;
function NotAnUpdate: Boolean;
begin
result := not IsUpdate;
end;
The answer by #AndreasRejbrand won't work, if user chooses to install the executable to a different location than the last time.
You can query installer-specific Inno Setup registry keys:
#define AppId "your-app-id"
#define SetupReg \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\" + AppId + "_is1"
#define SetupAppPathReg "Inno Setup: App Path"
[Setup]
AppId={#AppId}
...
[Run]
Filename: "https://www.example.com/"; Flags: shellexec; Check: not IsUpgrade
...
[Code]
function IsUpgrade: Boolean;
var
S: string;
begin
Result :=
RegQueryStringValue(HKLM, '{#SetupReg}', '{#SetupAppPathReg}', S) or
RegQueryStringValue(HKCU, '{#SetupReg}', '{#SetupAppPathReg}', S);
end;
For an example how to use IsUpgrade in [Code] section, see
Excludes part of Code section in ssPostInstall step if installation is update in Inno Setup
Check this if your "AppId" contains a left-curly-bracket:
Checking if installation is fresh or upgrade does not work when AppId contains a curly bracket
I am trying to use the idea from Inno Setup - How to hide certain filenames while installing? (FilenameLabel)
The only sure solution is to avoid installing the files, you do not want to show, using the [Files] section. Install them using a code instead. Use the ExtractTemporaryFile and FileCopy functions
But the files that I want to hide are using in the [Run] Section:
[Files]
Source: "_Redist\DXWebSetup.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
[Run]
Filename: "{tmp}\DXWebSetup.exe"; Components: DirectX; StatusMsg: "Installing DirectX..."; \
BeforeInstall: StartWaitingForDirectXWindow; AfterInstall: StopWaitingForDirectXWindow
How to hide (while installing, in filenamelabel) using [Files] section, ExtractTemporaryFile and FileCopy functions?
The easiest is to give up on the standard [Files] and [Run] sections and code everything on your own in the CurStepChanged event fuction:
[Files]
Source: "dxwebsetup.exe"; Flags: dontcopy
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ProgressPage: TOutputProgressWizardPage;
ResultCode: Integer;
begin
if CurStep = ssInstall then { or maybe ssPostInstall }
begin
if IsComponentSelected('DirectX') then
begin
ProgressPage := CreateOutputProgressPage('Installing prerequsities', '');
ProgressPage.SetText('Installing DirectX...', '');
ProgressPage.Show;
try
ExtractTemporaryFile('dxwebsetup.exe');
StartWaitingForDirectXWindow;
Exec(ExpandConstant('{tmp}\dxwebsetup.exe'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
finally
StopWaitingForDirectXWindow;
ProgressPage.Hide;
end;
end;
end;
end;
This even gives you a chance to check for results of the sub-installer. And you can e.g. prevent the installation from continuing, when the sub-installer fails or is cancelled.
Then it's easier to use the PrepareToInstall instead of the CurStepChanged.
Another option is to display a custom label, while extracting the sub-installer.
See Inno Setup - How to create a personalized FilenameLabel with the names I want?
I have an issue with the Inno Setup uninstaller. I have a exe file I want to executable to keep track of the installation and uninstallations. The exe is really simple and sends a message to a server.
[Files]
Source: "Tracker\LocalSandboxInstallTracker.exe"; DestDir: "{app}/Tracker";
Source: "Tracker\LocalSandboxInstallTracker.exe.config"; DestDir: "{app}/Tracker";
Source: "Tracker\Tracker.Client.dll"; DestDir: "{app}/Tracker";
[Run]
Filename: "{app}\Tracker\LocalSandboxInstallTracker.exe"; Parameters: " {#MyAppVersion} install"; Flags: runhidden; StatusMsg: "Sending tracking data..."
[Code]
procedure InitializeUninstallProgressForm();
var
ResultCode: Integer;
begin
Exec ('{app}\Tracker\LocalSandboxInstallTracker.exe',' {#MyAppVersion} uninstall','',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
The call at the installation works well, but not at the uninstall. I placed a breakpoint to my Exec command and it really goes through there, but the exe does not seem to be called.
You must expand the {app} constant before passing it to the Exec script function. Use the ExpandConstant whenever you need to get the value of the constant. Modify your script this way:
Exec(ExpandConstant('{app}\Tracker\LocalSandboxInstallTracker.exe'),
'{#MyAppVersion} uninstall', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
Also, you should check the function result and the output result code to react when the Exec function fails. The error code you'll get in the ResultCode you can check against the System Error Codes reference or use SysErrorMessage(ResultCode) to get the error description from script.
You have to call the ExpandConstant function if you want to use constants like {app} in your Exec call:
[Code]
procedure InitializeUninstallProgressForm();
var
ResultCode: Integer;
begin
Exec (ExpandConstant('{app}\Tracker\LocalSandboxInstallTracker.exe')
,' {#MyAppVersion} uninstall','',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
Other way, you're failing to locate the exe.
My InnoSetup script opens a web page (with the user's default browser) at the end of the install process:
[Run]
Filename: http://example.com; Flags: shellexec
However, I'd like the web page to not be opened if the app already exists, i.e., if the user is installing a new version of the program. The web page should only be opened after the initial install. (I assume it's worth mentioning that the install includes an AppID, obviously, and enters values in the registry beside installing files.)
Thank you, as always -- Al C.
Yes, this is easy to do with scripting.
Just write
[Run]
Filename: "http://example.com"; Flags: shellexec; Check: NotAnUpdate
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
IsUpdate := FileExists(ExpandConstant('{app}\TheFileNameOfMyApp.exe'));
end;
function NotAnUpdate: Boolean;
begin
result := not IsUpdate;
end;
The answer by #AndreasRejbrand won't work, if user chooses to install the executable to a different location than the last time.
You can query installer-specific Inno Setup registry keys:
#define AppId "your-app-id"
#define SetupReg \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\" + AppId + "_is1"
#define SetupAppPathReg "Inno Setup: App Path"
[Setup]
AppId={#AppId}
...
[Run]
Filename: "https://www.example.com/"; Flags: shellexec; Check: not IsUpgrade
...
[Code]
function IsUpgrade: Boolean;
var
S: string;
begin
Result :=
RegQueryStringValue(HKLM, '{#SetupReg}', '{#SetupAppPathReg}', S) or
RegQueryStringValue(HKCU, '{#SetupReg}', '{#SetupAppPathReg}', S);
end;
For an example how to use IsUpgrade in [Code] section, see
Excludes part of Code section in ssPostInstall step if installation is update in Inno Setup
Check this if your "AppId" contains a left-curly-bracket:
Checking if installation is fresh or upgrade does not work when AppId contains a curly bracket