Skip to content

Commit

Permalink
Merge pull request #1806 from winstliu/user/winstonliu/fix-sc-create-…
Browse files Browse the repository at this point in the history
…arguments

Point GVFS.Service to the correct executable when C:\Program exists
  • Loading branch information
dscho authored Oct 24, 2024
2 parents df8c9eb + df6a1ea commit f892a51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion GVFS/GVFS.Installers/Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,12 @@ begin
WizardForm.StatusLabel.Caption := 'Installing GVFS.Service.';
WizardForm.ProgressGauge.Style := npbstMarquee;
// Spaces after the equal signs are REQUIRED.
// https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create#remarks
try
if Exec(ExpandConstant('{sys}\SC.EXE'), ExpandConstant('create GVFS.Service binPath="{app}\GVFS.Service.exe" start=auto'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
// We must add additional quotes to the binPath to ensure that they survive argument parsing.
// Without quotes, sc.exe will try to start a file located at C:\Program if it exists.
if Exec(ExpandConstant('{sys}\SC.EXE'), ExpandConstant('create GVFS.Service binPath= "\"{app}\GVFS.Service.exe\"" start= auto'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
begin
if Exec(ExpandConstant('{sys}\SC.EXE'), 'failure GVFS.Service reset= 30 actions= restart/10/restart/5000//1', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
begin
Expand Down

0 comments on commit f892a51

Please sign in to comment.