1 월에 다시 물어 보았지만 이것을 알아 냈습니까?
val1, val2 등을 어디서 소싱하는지 잘 모르겠습니다. 사용자가 설치 프로세스에서 양식의 필드에 입력 했습니까? 그들이 있다고 가정하면, 이것은 내가 잠시 뒤돌아 볼 때와 비슷한 문제입니다.
내 접근 방식은 필요한 필드 (텍스트 필드 개체)로 구성 가능한 폼을 가지며 텍스트 필드의 값 (텍스트 필드의 '사용자 입력/변수 이름'범주 아래)에 할당 된 변수를 갖고있는 것이 분명합니다. 텍스트 필드).
나중에 설치 프로세스에서 디스플레이 진행률 화면에 실행 스크립트 조치가 첨부되어 일부 Java에서 수행하려는 작업을 수행했습니다.
선택적으로이 방법으로 install4j에서 변수를 설정할 때 두 가지 '문제'가 있습니다. 첫째, 빈 문자열에만있는 경우에도 변수 HAS는 무엇이든 상관없이 설정해야합니다. 따라서 사용자가 필드를 공백으로두면 (즉, 해당 인수를 서비스에 전달하지 않으려는 경우) 실행 파일 또는 서비스 시작 작업에 빈 문자열을 제공해야합니다.) 둘째, 인수에는 공백이 없어야합니다. 공백으로 구분 된 모든 인수에는 고유 한 줄이 있어야합니다.
final String[] argumentNames = {"arg1", "arg2", "arg3"};
// For each argument this method creates two variables. For example for arg1 it creates
// arg1ArgumentIdentifierOptional and arg1ArgumentAssignmentOptional.
// If the value of the variable set from the previous form (in this case, arg1) is not empty, then it will
// set 'arg1ArgumentIdentifierOptional' to '--arg', and 'arg1ArgumentAssignmentOptional' to the string arg1=val1 (where val1
// was the value the user entered in the form for the variable).
// Otherwise, both arg1ArgumentIdentifierOptional and arg1ArgumentAssignmentOptional will be set to empty.
//
// This allows the installer to pass both parameters in a later Run executable task without worrying about if they're
// set or not.
for (String argumentName : argumentNames) {
String argumentValue = context.getVariable(argumentName)==null?null:context.getVariable(argumentName)+"";
boolean valueNonEmpty = (argumentValue != null && argumentValue.length() > 0);
context.setVariable(
argumentName + "ArgumentIdentifierOptional",
valueNonEmpty ? "--arg": ""
);
context.setVariable(
argumentName + "ArgumentAssignmentOptional",
valueNonEmpty ? argumentName+"="+argumentValue : ""
);
}
return true;
마지막 단계는 서비스 나 실행 파일을 실행하는 것입니다 염두에두고
, 여기 당신이 원하는 것을 얻을 수있는 스크립트 실행 코드입니다. 서비스가 어떻게 작동하는지 잘 모르겠지만 실행 파일을 사용하여 작업을 생성 한 다음 '인수'필드를 편집하여 줄로 구분 된 값 목록을 제공합니다.
--install
${installer:arg1ArgumentIdentifierOptional}
${installer:arg1ArgumentAssignmentOptional}
${installer:arg2ArgumentIdentifierOptional}
${installer:arg2ArgumentAssignmentOptional}
${installer:arg3ArgumentIdentifierOptional}
${installer:arg3ArgumentAssignmentOptional}
"내 서비스 NAME1 '
을 그리고 그것 뿐이다 :
그래서 귀하의 경우, 그것은 다음과 같을 수 있습니다. 다른 사람이이 방법을 잘 알고 있다면이 방법으로 개선하는 것이 좋습니다 (install4j 4.2.8, btw).