我一直在尝试使用 Inno Setup 为我的 vb.net 应用程序创建安装程序。
此应用程序先决条件依赖于 MySQL ODBC。所以,我在想是否可以检查系统是否存在 MySQL ODBC,如果不存在则安装。好吧,坦率地说,我是一名新手程序员,我对 debian 一无所知,它是 InnoSetup 的脚本语言。
一段时间以来,我一直在通过谷歌和其他东西寻求帮助,但除了一些示异常(exception)找不到任何其他东西,因此我尝试自己编写脚本。
这是脚本:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[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={{ID goes here}
AppName=DCS
AppVersion=1.0
;AppVerName=DCS 1.0
AppPublisher=Syed
DefaultDirName={pf}\DCS
DisableDirPage=yes
DefaultGroupName=DCS
DisableProgramGroupPage=yes
OutputBaseFilename=setup
SetupIconFile=C:\logo.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.application"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.application"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\DCS.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\VS12\Projects\DCS\bin\Debug\mysql-connector-odbc-5.1.12-win32.msi"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[code]
function IsMySQLOdbcInstalled(): boolean;
begin
If NOT RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\ODBC\ODBCINST.INI\MySQL ODBC 5.1 Driver') then
Result := True
Else
Result := False;
end;
[Icons]
Name: "{group}\DCS"; Filename: "{app}\DCS.exe"
Name: "{commondesktop}\DCS"; Filename: "{app}\DCS.exe"; Tasks: desktopicon
[Run]
Filename: {src}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled()
Filename: "{app}\DCS.exe"; Description: "{cm:LaunchProgram,DCS}"; Flags: nowait postinstall skipifsilent
现在,编译正常,并生成一个 setup.exe 可执行文件。运行时,应用程序 DCS 得到安装,但 MySQL ODBC 没有并给出错误,
Unable to execute file:
'Output path'\mysql-connector-odbc-5.1.12-win32.msi
Create Process failed; code2.
The system cannot find the file specified.
OK
我认为输出文件夹需要 mysql-connector-odbc msi 安装文件夹。只是为了检查,我手动复制它,重新编译并运行安装程序,只是为了得到相同的结果,但有一些变化:
Unable to execute file:
'Output path'\mysql-connector-odbc-5.1.12-win32.msi
Create Process failed; code193.
%1 is not a vaild Win32 application.
OK
此外,我希望安装程序在进行任何安装之前检查 MySQL ODBC 驱动程序,但在这里,它是在主应用程序安装之后检查的。任何人都可以帮我更正这个脚本吗?
谢谢
最佳答案
问题出在您的 [Run] 部分。您将从 {src} 路径执行该 MySQL ODBC 安装程序。由于您将 mysql-connector-odbc-5.1.12-win32.msi 安装程序文件复制到 {app} 文件夹,因此您必须从同一文件夹运行它。以这种方式修复脚本的 [Run] 部分:
[Run]
; on the following line, run the executable from the {app} directory instead
; of {src}; the {src} folder is the folder in which the Setup files are located
; since it is not an *.exe file, you must also specify the shellexec flag
Filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled(); Flags: shellexec
Filename: "{app}\DCS.exe"; Description: "{cm:LaunchProgram,DCS}"; Flags: nowait postinstall skipifsilent
更新:
为了满足您的额外要求,在主要安装过程之前运行 ODBC 驱动程序安装程序,我制作了以下脚本示例(仅保留与 ODBC 驱动程序设置相关的部分)。
无论如何,我想如果你在一些默认设置的静默模式下运行 ODBC 驱动程序安装程序可能不会那么烦人,所以它不会向用户提供向导(如果有的话)(但这是更广泛的主题问题;将有参数来控制 ODBC 驱动程序安装程序,而那些您可以传递给 Exec 函数的第二个参数的参数可能会告诉显示窗口标志为 SW_HIDE SW_SHOWNORMAL,这将使它对用户隐藏)。请注意,此代码未经测试:
[Setup]
AppName=DCS
AppVersion=1.0
DefaultDirName={pf}\DCS
[Files]
; keep just the only one flag, "dontcopy"; it will tell the installer to not copy
; this file entry to the target machine, but will be part of the setup binary and
; available for manual extracting by using the ExtractTemporaryFile(s) function
Source: "C:\VS12\Projects\DCS\bin\Debug\mysql-connector-odbc-5.1.12-win32.msi"; Flags: dontcopy
[Run]
; remove the ODBC driver installer entry from [Run] section since the [Run] section
; is executed after the installation is succesfully finished and your requirement is
; to run it before the installation process
; Filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; Check: IsMySQLOdbcInstalled()
[Code]
function IsMySQLODBC51Installed: Boolean;
begin
// the result was inverted in the original code; the original function returned
// True if the ODBC driver was not installed, False otherwise, and according to
// the function name it should be vice-versa
Result := RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\ODBC\ODBCINST.INI\MySQL ODBC 5.1 Driver');
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
// if we are right before the main installation starts and ODBC driver is not yet
// installed, then...
if (CurStep = ssInstall) and not IsMySQLODBC51Installed then
begin
// now extract the ODBC installaer to the Inno Setup's temporary folder
ExtractTemporaryFile('mysql-connector-odbc-5.1.12-win32.msi');
// and execute the ODBC driver installation (it is necessary to use ShellExec
// since it is not an *.exe file); if the execution fails, then...
if not ShellExec('', ExpandConstant('{tmp}\mysql-connector-odbc-5.1.12-win32.msi'), '', '',
SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
begin
// show the error message with exit code
MsgBox('MySQL ODBC Driver setup failed!' + #13#10 + 'Exit code: ' + IntToStr(ResultCode) +
'; ' + SysErrorMessage(ResultCode), mbError, MB_OK);
// here you can optionally call Abort to abort the upcoming installation process
// so if you uncomment the following line, the main installation will not run if
// the ODBC driver installer execution failed
// Abort;
end;
end;
end;
关于mysql - InnoSetup + MySQL ODBC 脚本 = 错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19218918/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee