Combreal

InstallWSL.iss

May 26th, 2020
1,275
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5. DisableFinishedPage=yes
  6. OutputDir=C:\Temp
  7.  
  8. [Code]
  9. var
  10.   NeedRestartFlag: Boolean;
  11.  
  12. procedure CurStepChanged(CurStep: TSetupStep);
  13. var
  14.   ResultCode: Integer;
  15.  begin
  16.   if CurStep = ssInstall then
  17.   begin
  18.     if (FileExists('C:\Windows\System32\bash.exe')) then
  19.     begin
  20.       NeedRestartFlag := True
  21.       Exec(ExpandConstant('dism.exe'), '/quiet /NoRestart /online /Enable-Feature /featurename:Microsoft-Windows-Subsystem-Linux', '', SW_HIDE, ewNoWait, ResultCode);
  22.       Sleep(850)
  23.     end
  24.     else
  25.     begin
  26.       NeedRestartFlag := False
  27.     end
  28.   end;
  29. end;
  30.  
  31. function NeedRestart(): Boolean;
  32. begin
  33.   if NeedRestartFlag then
  34.   begin
  35.     Log('Need restart');
  36.     Result := True;
  37.   end
  38.     else
  39.   begin
  40.     Log('Do not need restart');
  41.     Result := False;
  42.   end;
  43. end;
RAW Paste Data