How to get the Inno Setup / DIR command line switch to work with a custom path page

When I use the / DIR command line switch

 "Mysoft.exe" /VERYSILENT /installerbusiness /DIR="C:\Program Files (x86)" 

The specified path is not used for the path field on my user page:

I am using code based on Use two / more selected directories from the user page in the Files section .

This is an example of the code I use.

 [Code] var Install: TInputDirWizardPage; procedure InitializeWizard(); begin Install := CreateInputDirPage( wpSelectDir, CustomMessage('Readyinstall'), CustomMessage('Readyinstallpc'), #13#10#13#10 + CustomMessage('Tocontinuet'), True, 'Mysoft'); Install.Add(CustomMessage('DestFolder')); Install.Values[0] := ('C:\Program Files\Mysoft'); { ... } end; 
+1
source share
1 answer

If you want the standard behavior of the "installation path" of Inno Setup to include command line processing /DIR= , you must bind your own path to the standard one.

So, you should copy the original WizardForm.DirEdit value to your own checkbox:

 var Page: TInputDirWizardPage; procedure InitializeWizard(); begin ... Page := CreateInputDirPage(...); Page.Add(...); Page.Values[0] := WizardForm.DirEdit.Text; end; 

This solution handles not only /DIR= , but also /LOADINF= .

To complement the above code, you must copy the value back to WizardForm.DirEdit . Thus, make sure that when you reinstall / upgrade, the previously selected value is reused. This is shown in paragraph 1) of my response to Use two / more selected directories from a user page in the Files section .


If the above is too complicated (or not obvious) to implement, due to the complex logic of your installer, you can handle the software /DIR= programmatically yourself. See Setting the value of the Inno Setup custom configuration field from the command line .

 procedure InitializeWizard(); var DirSwitchValue: string; begin Install := ...; Install.Add(...); DirSwitchValue := ExpandConstant('{param:DIR}'); if DirSwitchValue <> '' then begin Install.Values[0] := DirSwitchValue; end else begin Install.Values[0] := ExpandConstant('{pf}\Mysoft'); end; end; 

This solution obviously does not handle /LOADINF= . How to process .inf files is shown in Inno Setup Download default values ​​for custom installation settings from a file (.inf) for silent installation .

In addition, with this solution, the previously used installation path will not be used for upgrades / reinstallations. How to implement this is shown in Inno Setup with three destination folders .

+1
source

Source: https://habr.com/ru/post/974791/


All Articles