I have a Inno Setup file containing code like :
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"
#define MyAppExeName "Vytelle.DataService.Worker.exe"
#define MyAppAssocName MyAppName " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") MyAppAssocExt
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{72A0FB9B-516C-472D-886D-4DA0727FD72C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=mysetup
OutputDir=D:\
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "D:\vytelle.dataservice\Vytelle.DataService\Vytelle.DataService.Worker\bin\Debug\net7.0\publish\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: {sys}\sc.exe; Parameters: "create ByTestService start= auto binPath=""""{app}\{#MyAppExeName}"" ThisisParameter" ; Flags: runhidden
But after installing, getting process code 1639 (wrong arguments error code)
Just want to know how to pass parameter with sc create
command as you see in the run script of the give code.
CodePudding user response:
You have two problems:
- You are missing the trailing quote (needs to be doubled according to Inno Setup syntax).
- The inner quotes in
binPath
need to be escaped.
See When creating a service with sc.exe how to pass in context parameters?
So your commandline won't work even standalone, let alone in Inno Setup.
The correct syntax is:
"create ByTestService start= auto binPath=""\""{app}\{#MyAppExeName}\"" ThisisParameter"""
Note: the backslash in \""
(twice) and the three trailing quotes """
(first two for trailing quote in sc
binPath
and the third to match the leading quote in Parameters
).
This ultimately executes:
cs create ByTestService start= auto binPath="\"C:\Program Files (x86)\Accenture\Vytelle.DataService.Worker.exe\" ThisisParameter"