Just wondering if any has an example of how to call a multi-line command using the Exec?
I essentially have several steps that are each Exec command eg, if I was doing this from a batch file it would be
Step 1.
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
Step 2.
FOR /F "delims=" %%i IN ('DISM /Online /Get-CapabilityInfo /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0') DO (
if "%%i"=="State : Not Present" (
DISM /Online /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
)
)
From an API perspective, there's really no such thing as a multi-line command.
My advice, rather than using a batch file, would be to implement the registry value in your [Registry] section and the Windows capability part in the [Code] section.
For the registry part:
[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"; ValueType: dword; ValueName: "AllowDevelopmentWithoutDevLicense"; ValueData: 1
For the Windows capability part, I would recommend using Get-WindowsCapability/Add-WindowsCapability in PowerShell.
You probably want to run the PowerShell code during the ssInstall event of the CurStepChanged event procedure; e.g.:
procedure CurStepChanged(CurStep: TSetupSetup);
var
ResultCode: integer;
begin
if CurStep = ssInstall then
begin
Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-Command "if (
(Get-WindowsCapability -Online -Name ''Tools.DeveloperMode.Core~~~~0.0.1.0'').State -eq ''NotPresent'' ) {
Add-WindowsCapability -Online -Name ''Tools.DeveloperMode.Core~~~~0.0.1.0'' }"', '', 0, true, ResultCode);
end;
end;
Bill