【问题标题】:InstallScript and machine.configInstallScript 和 machine.config
【发布时间】:2014-04-23 14:02:28
【问题描述】:

我在使用 InstallScript 时遇到了一些我似乎无法弄清楚的问题。主要的是我需要在 machine.config 文件中添加以下内容:

<system.transactions>
    <machineSettings maxTimeout="02:00:00" />
</system.transactions>

但它是这样添加的:

<system.transactions>
    <machineSettings>
        <maxTimeout>"02:00:00"</maxTimeout>
    </machineSettings>
</system.transactions>

这是我用来更新文件的代码(消息框用于调试目的)。

function STRING GetMachineConfigPath(hMSI)
    STRING strRetVal;
    NUMBER nSize, nType;
begin
    nSize = MAX_PATH - 1;
    MsiGetProperty(ISMSI_HANDLE, "MACHINECONFIGPATH", strRetVal, nSize);
    return strRetVal;
end;

function SaveMachineConfigSettings(hMSI) 
    OBJECT oDoc; // XML Document object 
    OBJECT oNode; // A node in the XML DOM tree 
    OBJECT CurrParent; // Current parent node 
    STRING szFilename;
    BOOL successfulLoad;
begin

    szFilename = GetMachineConfigPath(hMSI) + "config\\machine.config";

    if Is(FILE_EXISTS, szFilename) = FALSE then
        MessageBox("Could not find machine.config file.", 0);
        return -1;
    endif;

    set oDoc = CreateObject("Msxml2.DOMDocument");
    if (IsObject(oDoc) = FALSE) then
        MessageBox("Could not open machine.config file.", 0);
        return -1;
    endif;

    oDoc.Async = FALSE; 
    oDoc.setProperty("SelectionLanguage", "XPath");

    successfulLoad = oDoc.load(szFilename);
    MessageBox("File loaded successfully.", 0);

    if (successfulLoad = FALSE) then
        MessageBox("File did not load successfully.", 0);
        return -1;
    endif;

    set CurrParent = oDoc.documentElement;
    set oNode = AddSetting(oDoc, CurrParent, "system.transactions", ""); 
    set CurrParent = oNode; 
    set oNode = AddSetting(oDoc, CurrParent, "machineSettings", "");
    set CurrParent = oNode;
    set oNode = AddSetting(oDoc, CurrParent, "maxTimeout", '"02:00:00"');

    // Write the XML document to a file. 
    oDoc.save(szFilename);

    MessageBox("File updated successfully.", 0);

    set oNode = NOTHING; 
    set oDoc = NOTHING; 

    return 0;
end; 

function OBJECT AddSetting(oDoc, oParent, szNodeName, szValue) 
    OBJECT oNode;
begin 
    // Add a carriage return & line feed to make the output easier to read. 
    set oNode = oDoc.createTextNode("\n"); 
    oParent.appendChild(oNode); 

    // Create the new setting node and value. 
    set oNode = oDoc.createElement(szNodeName); 
    oNode.text = szValue; 
    oParent.appendChild(oNode);

    MessageBox("Node created successfully.", 0);

    return oNode; 
end; 

非常感谢您提供的任何帮助!

【问题讨论】:

  • 我最终创建了一个 C# 控制台应用程序来修改文件,然后从 InstallShield 安装运行该 EXE。这给了我更多的灵活性和对文件修改的控制,以避免引起问题。
  • 您应该在自我回答(而不是作为评论)中记录您如何解决问题并接受它。否则,这个问题似乎仍然没有答案。
  • 将其添加为答案,对此感到抱歉。

标签: installscript machine.config


【解决方案1】:

我最终创建了一个 C# 控制台应用程序来修改文件,然后从 InstallShield 安装运行该 EXE。这给了我更多的灵活性和对文件修改的控制,以避免引起问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 2011-01-20
    • 2012-03-07
    • 1970-01-01
    相关资源
    最近更新 更多