简体   繁体   中英

Run java file in inno setup

I have program in java who are copying some files to home java folders. In cmd it's work. I don't know how use it in Inno Setup.

I tried:

Filename: "{cmd}"; Parameters: "/C ""cd {app}""/C ""java Javaxcomm"; Flags: runhidden waituntilterminated runascurrentuser
Filename: "java"; Parameters: "Javaxcomm"; WorkingDir: "{app}";  Flags: runhidden waituntilterminated runascurrentuser
Filename: "cmd"; Parameters: "/C java {app}\Javaxcomm"

I found another way. Maybe someone this will help. It isn't my code.

[Code]
var
  javaVersion: String;
  javaPath: String;

function InitializeSetup(): Boolean;
begin
  if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit', 'CurrentVersion') then
    begin
      RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit', 'CurrentVersion', javaVersion);
      MsgBox('Found Java Development Kit version ' + javaVersion, mbInformation, MB_OK);
      if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit\' + javaVersion, 'JavaHome') then
        begin
          RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Development Kit\' + javaVersion, 'JavaHome', javaPath);
          MsgBox('Found Java Development Kit java_home: ' + javaPath, mbInformation, MB_OK);
          Result := True;
        end
      else
        begin
          MsgBox('Java Path not set for JDK' + javaVersion, mbInformation, MB_OK);
          MsgBox('RE-install java', mbInformation, MB_OK);
          Result := False;
        end
    end
  else if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion') then
    begin
      RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', javaVersion);
      MsgBox('Found Java Runtime Environment version ' + javaVersion, mbInformation, MB_OK);
      if RegValueExists(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\' + javaVersion, 'JavaHome') then
        begin
          RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\' + javaVersion, 'JavaHome', javaPath);
          MsgBox('Found Runtime Environment java_home: ' + javaPath, mbInformation, MB_OK);
          Result := True;
        end
      else
        begin
          MsgBox('Java Path not set for Java Runtime Environment' + javaVersion, mbInformation, MB_OK);
          MsgBox('RE-install java', mbInformation, MB_OK);
          Result := False;
        end
    end
  else
    begin
      MsgBox('v1 has not been found on your computer.'#13#13'Please Install it and try again.', MbError, Mb_Ok);
      Result := False;
    end
end;

function GetJAVAHome(S: String) : String;
begin
  Result := javaPath;
end;
Source: "{#MojaAppZrodla}\commapi\comm.jar"; DestDir: "{code:GetJAVAHome}\lib\ext"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MojaAppZrodla}\commapi\win32com.dll"; DestDir: "{code:GetJAVAHome}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MojaAppZrodla}\commapi\javax.comm.properties"; DestDir: "{code:GetJAVAHome}\lib"; Flags: ignoreversion recursesubdirs createallsubdirs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM