“Inno Setup 编译器”如何打包 javaWeb 应用程序,自动设置环境变量

1318953725 2009-08-17 10:48:50
各位高手:
您们好!
我做了一个javaWeb 应用程序,现在想用 “Inno Setup 编译器” 打包,不知java的环境变量怎么添加;想实现的效果是
当程序安装好后,环境变量也随着配置好。根据选择的安装目录,自动将环境变量装好。谢谢各位了。麻烦告诉一声。
------------------------------- 以下是脚本怎么加 ---------------------------------------------------------
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{978F3205-A281-4ECD-AFAB-5BB49CBACA44}
AppName=javaWeb程序
AppVerName=我的程序 1.5
AppPublisher=我的公司
AppPublisherURL=http://127.0.0.1:8080/
AppSupportURL=http://127.0.0.1:8080/
AppUpdatesURL=http://127.0.0.1:8080/
DefaultDirName=d:\jxc\javaWeb程序
DefaultGroupName=javaWeb程序
LicenseFile=C:\Documents and Settings\Administrator\桌面\新建 文本文档.txt
InfoBeforeFile=C:\Documents and Settings\Administrator\桌面\新建 文本文档.txt
InfoAfterFile=C:\Documents and Settings\Administrator\桌面\新建 文本文档.txt
OutputDir=D:\jxc
OutputBaseFilename=setup
SetupIconFile=C:\Documents and Settings\Administrator\桌面\Cczt.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "F:\项目_备份\mxj\2009-08-04\webjxc\build\web\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,javaWeb程序}"; Filename: "http://127.0.0.1:8080/"
Name: "{group}\{cm:UninstallProgram,javaWeb程序}"; Filename: "{uninstallexe}"
...全文
641 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nixjojo 2010-05-05
  • 打赏
  • 举报
回复
顶啊。我也想知道。
其实,只要知道怎么动态获得安装路径,然后改写bat文件,再去执行bat文件就可以设置环境变量了。
关键是,如何自动改写bat文件呢?
1318953725 2009-08-18
  • 打赏
  • 举报
回复
回贴的人好少哦!!有没有人准确用这个打过 javaWeb 包的。如果有的话。能不能贴个 *.iss 出来嘛!麻烦了。
knightzhuwei 2009-08-17
  • 打赏
  • 举报
回复
帮顶
threenewbee 2009-08-17
  • 打赏
  • 举报
回复
http://restools.hanzify.org/inno/other/Isxkbchm.zip

这个里面有很多有用的脚本可以参考。
threenewbee 2009-08-17
  • 打赏
  • 举报
回复



[Code]

// Version log:
// 09/22/2005: Initial release (axis23(at)gmail.com)
// Based in 'Native ISX procedures for PATH modification' from Thomas Vedel ('ModifyPath.iss')

const
// Modification method
vmAddOnlyIfVarDoesNotExists = $1; // Add Var only is this Var doesn't exists
vmAddAllways = $2; // Add Var allways

// Scope
vsCurrentUser = 1; // Add Var for current user
vsAllUsers = 2; // Add Var for all users

// Error results
mvOK = 0; // No errors
mvMissingRights = -1; // User has insufficient rights
mvAutoexecNoWriteacc = -2; // Autoexec can not be written (may be readonly)
mvBothMethods = -3; // Error if invoque function with two methods

{ Helper function: Modify Var on Windows 9x }
function ModifyVar9x(VarName, VarValue: string; Method: integer): integer;
var
AutoexecLines: TStringList;
ActualLine: String;
VarLineNos: TStringList;
FirstVarLineNo: Integer;
VarExists: boolean;
LineNo, CharNo, Index: integer;

TempString: String;
TempVarName: String;
TempVarName_comp: String;

begin
// Expect everything to be OK
result := mvOK;

// Create stringslists
AutoexecLines := TStringList.Create;
VarLineNos := TStringList.Create;
TempVarName := 'SET ' + uppercase(VarName) + '=';
TempVarName_comp := 'SET' + uppercase(VarName) + '=';

// Create VarExists
VarExists := false;

// Read existing Var
LoadStringFromFile('c:Autoexec.bat', TempString);
AutoexecLines.Text := TempString;
VarLineNos.Clear;
// Read Autoexec line by line
for LineNo := 0 to AutoexecLines.Count - 1 do begin
ActualLine := AutoexecLines.Strings[LineNo];
// Check if line starts with 'Varname=' after first stripping spaces and other "fill-chars"
if Pos('=', ActualLine) > 0 then
begin
for CharNo := Pos('=', ActualLine)-1 downto 1 do
if (ActualLine[CharNo]=' ') or (ActualLine[CharNo]=#9) then
Delete(ActualLine, CharNo, 1);
if Pos('@', ActualLine) = 1 then
Delete(ActualLine, 1, 1);
if (Pos(TempVarName_Comp, uppercase(ActualLine))=1) then
begin
ActualLine := TempVarName + VarValue;
// Update list of line numbers holding VarName variables
VarLineNos.Add(IntToStr(LineNo));
VarExists :=true;
end;
end;
end;

// Save first line number in Autoexec.bat which modifies Var environment variable
if VarLineNos.Count > 0 then
FirstVarLineNo := StrToInt(VarLineNos.Strings[0])
else
FirstVarLineNo := 0;

// Only change autoexec if method permit this
if ((Method = vmAddAllways) or ((Method = vmAddOnlyIfVarDoesNotExists) and (VarExists=false))) then
begin
// Write Modified Var back to Autoexec.bat
// First delete all existing Var references from Autoexec.bat
Index := VarLineNos.Count-1;
while (Index>=0) do
begin
AutoexecLines.Delete(StrToInt(VarLineNos.Strings[Index]));
Index := Index-1;
end;
// Then insert new Var variable into Autoexec.bat
if(VarExists=false) then
FirstVarLineNo := AutoexecLines.Count;
AutoexecLines.Insert(FirstVarLineNo, TempVarName+VarValue);
// Delete old Autoexec.bat from disk
if not DeleteFile('c:Autoexec.bat') then
result := mvAutoexecNoWriteAcc;
Sleep(500);
// And finally write Autoexec.bat back to disk
if not (result=mvAutoexecNoWriteAcc) then
SaveStringToFile('c:Autoexec.bat', AutoexecLines.Text, false);
end;

// Free stringlists
VarLineNos.Free;
AutoexecLines.Free;
end; // ModifyVar9x


{ Helper function: Modify Var on Windows NT, 2000 and XP }
function ModifyVarNT(VarName, VarValue: string; Method, Scope: integer): integer;
var
RegRootKey: integer;
RegSubKeyName: string;
RegValueName: string;
ResultVar: string;
OK: boolean;
begin
// Expect everything to be OK
result := mvOK;

// Initialize registry key and value names to reflect if changes should be global or local to current user only
case Scope of
vsCurrentUser:
begin
RegRootKey := HKEY_CURRENT_USER;
RegSubKeyName := 'Environment';
RegValueName := VarName;
end;
vsAllUsers:
begin
RegRootKey := HKEY_LOCAL_MACHINE;
RegSubKeyName := 'SYSTEMCurrentControlSetControlSession ManagerEnvironment';
RegValueName := VarName;
end;
end;

// Read current Var value from registry
OK := RegQueryStringValue(RegRootKey, RegSubKeyName, RegValueName, ResultVar);

// Write new Var value to registry
if ((Method = vmAddAllways) or ((Method = vmAddOnlyIfVarDoesNotExists) and (OK=false))) then
begin
if not RegWriteStringValue(RegRootKey, RegSubKeyName, RegValueName, VarValue) then
begin
result := mvMissingRights;
Exit;
end;
end;
end; // ModifyVarNT


{ Main function: Modify Var }
function ModifyVar(VarName, VarValue: string; Method, Scope: integer): integer;
begin
// Check if both add and remove has been specified (= error!)
if (Method and (vmAddOnlyIfVarDoesNotExists and vmAddAllways)) > 0 then
begin
result := mvBothMethods;
Exit;
end;

// Test if Win9x
if InstallOnThisVersion('4,0','0,0') = irInstall then
ModifyVar9x(VarName,VarValue, Method);

// Test if WinNT, 2000 or XP
if InstallOnThisVersion('0,4','0,0') = irInstall then
ModifyVarNT(VarName, VarValue, Method, Scope);
end; // ModifyVar

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧