Office 2007 安装程序在启动脚本期间运行时不记录

Office 2007 安装程序在启动脚本期间运行时不记录

我正在使用启动脚本来部署 Microsoft Office 2007 Standard。它工作得不太好,我正在尝试查找它的日志信息。不幸的是,安装程序没有生成任何日志。我尝试将日志配置为 %temp%\、C:\、%systemroot%\temp 并将其保留为默认值,但都无济于事。事件日志中也没有显示任何内容。我还能去哪里查找有关安装程序正在发生什么的信息?

编辑:这是我当前正在运行的脚本:

// WSH System Objects
var shell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject")
var env = shell.Environment("Process");

// Well Known Constants
var EVENT_SUCCESS = 0;
var EVENT_ERROR = 1;
var EVENT_WARNING = 2;
var EVENT_INFORMATION = 4;
var EVENT_AUDIT_SUCCESS = 8;
var EVENT_AUDIT_FAILURE = 16;

// Custom Constants
var MESSAGE_DEPLOYMENT_START = "Outlook deployment started.";
var MESSAGE_ALREADY_DEPLOYED = "Deployment halted. Outlook already deployed at ";
var MESSAGE_ERROR_UNKOWN_GUID = "Deployment halted. An unknown Office product GUID has been detected.";
var MESSAGE_SETUP_STANDARD = "Initializing setup for Office12 Standard Edition. See Install log at " + env("TEMP") + "\\SetupExe(*).log";
var MESSAGE_SETUP_PROPLUS = "Initializing setup for Office12 Professional Plus. See install log at " + env("TEMP") + "\\SetupExe(*).log";
var MESSAGE_OFFICE_NOT_DETECTED = "Office was not detected; deployment aborted.";
var MESSAGE_OFFICE_VERSION_NOT_DETECTED = "Office version could not be detected; deployment aborted.";
var MESSAGE_UNKNOWN_ERROR = "An unknown error has occurred: ";
var MESSAGE_UNKNOWN_GUID = "Detected an unknown GUID";
var ECODE_CANNOT_READ_VALUE = 2;
var REG_OFFICE12_64 = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Office\\12.0\\";
var REG_OFFICE12_32 = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\12.0\\";
var REG_OFFICE12_REGISTRATION = "Registration";
var REG_OUTLOOK_INSTALL_LOCATION = "InstallRoot\\Path";
var DEPLOYMENT_SOURCE_STANDARD = "\"\\\\netapps\\apps\\Microsoft\\Office 2007 Standard\"";
var CONFIG_PATH_STANDARD = "\"\\\\netapps\\apps\\Microsoft\\Office 2007 Standard\\Config.xml\"";
var DEPLOYMENT_SOURCE_PROPLUS = "\"\\\\netapps\\apps\\Microsoft\\Office 2007 Professional Plus\"";
var CONFIG_PATH_PROPLUS = "\"\\\\netapps\\apps\\Microsoft\\Office 2007 Professional Plus\\Config.xml\"";
var OFFICE12_STANDARD_GUID = "{90120000-0012-0000-0000-0000000FF1CE}";
var OFFICE12_PROPLUS_GUID = "{90120000-0011-0000-0000-0000000FF1CE}";

// Log start of script.
messageEnvironmentSettings = "Environment Settings: \n";
messageEnvironmentSettings += "%TEMP%: " + env("TEMP") + "\n";
messageEnvironmentSettings += "%SYSTEMROOT%: " + env("SYSTEMROOT") + "\n";
messageEnvironmentSettings += "%WINDIR%: " + env("WINDIR") + "\n";

shell.LogEvent(EVENT_INFORMATION, MESSAGE_DEPLOYMENT_START + "\n\n" + messageEnvironmentSettings);


//***************** Get root Office registry key.**************
var regOfficeRoot;

try
{
    shell.RegRead(REG_OFFICE12_64);
    regOfficeRoot = REG_OFFICE12_64;
}
catch (e)
{
    if ((e.number & 0xFFFF) == ECODE_CANNOT_READ_VALUE)
    {
        try 
        {
            shell.RegRead(REG_OFFICE12_32);
            regOfficeRoot = REG_OFFICE12_32;
        }       
        catch (e2)
        {
            if ((e2.number & 0xFFFF) == ECODE_CANNOT_READ_VALUE)
            {
                // Office is not installed. Log and quit.
                shell.LogEvent(EVENT_INFORMATION, MESSAGE_OFFICE_NOT_DETECTED);
                WScript.Quit(0);
            }
            else
            {
                shell.LogEvent(EVENT_ERROR, MESSAGE_UNKNOWN_ERROR + e2.message);
            }
        }
    }
    else
    {
        shell.LogEvent(EVENT_ERROR, MESSAGE_UNKNOWN_ERROR + e.message);
    }
}

//************************ Find out if Outlook is installed.*******************************
try
{
    var outlookInstallationLocation = shell.RegRead(regOfficeRoot + "Outlook\\" + REG_OUTLOOK_INSTALL_LOCATION);

    // Log and exit.
    shell.LogEvent(EVENT_INFORMATION, MESSAGE_ALREADY_DEPLOYED + "\"" + outlookInstallationLocation + "\"" );
    WScript.Quit(0);
}
catch (e)
{
    if ((e.number & 0xFFFF) == 2)
    {
        // Key didn't exist; Outlook is not installed. Supress registry read error.
    }
    else
    {
        shell.LogEvent(EVENT_ERROR, MESSAGE_UNKNOWN_ERROR + e.message);
    }
}




//***************** Discover version of office installed.**************
var detectedOfficeGuid;
try
{
    shell.RegRead(regOfficeRoot + "Registration\\" + OFFICE12_STANDARD_GUID + "\\");
    detectedOfficeGuid = OFFICE12_STANDARD_GUID;
}
catch (e)
{

    if ((e.number & 0xFFFF) == ECODE_CANNOT_READ_VALUE)
    {
        try
        {
            shell.RegRead(regOfficeRoot + "Registration\\" + OFFICE12_PROPLUS_GUID + "\\");
            detectedOfficeGuid = OFFICE12_PROPLUS_GUID;
        }
        catch (e)
        {
            shell.LogEvent(EVENT_ERROR, MESSAGE_OFFICE_VERSION_NOT_DETECTED);
            WScript.Quit(1);
        }
    }
    else
    {
        shell.LogEvent(EVENT_ERROR, MESSAGE_UNKNOWN_ERROR + e.message);
    }
}


//************************* Installation ******************************

if (detectedOfficeGuid == OFFICE12_STANDARD_GUID)
{
    var messageSetup = MESSAGE_SETUP_STANDARD;
    var deploymentCommand = DEPLOYMENT_SOURCE_STANDARD + "\\setup.exe /config " + CONFIG_PATH_STANDARD;
}
else if (detectedOfficeGuid = OFFICE12_PROPLUS_GUID)
{
    var messageSetup = MESSAGE_SETUP_PROPLUS;
    var deploymentCommand = DEPLOYMENT_SOURCE_STANDARD + "\\setup.exe /config " + CONFIG_PATH_STANDARD;
}
else
{
    shell.LogEvent(EVENT_ERROR, MESSAGE_ERROR_UNKNOWN_GUID);
    WScript.Quit(1);
}

shell.LogEvent(EVENT_INFORMATION, messageSetup + "\n" + deploymentCommand);
var setupExec = shell.exec(deploymentCommand);

shell.LogEvent(EVENT_INFORMATION, "Exit Code: " + setupExec.ExitCode);

答案1

好吧,我找到了问题所在。安装可执行文件在执行大部分操作之前就被 Windows 终止了,这让事情变得相当混乱。似乎安装程序没有正确完成其工作。

似乎安装可执行文件是异步调用的,Windows 没有等待它完成就继续启动过程。以下代码似乎解决了该问题:

while ( setupExec.Status == 0 )
{
    WScript.sleep(1000);
}

我在调用安装可执行文件后直接添加了此循环。它会检查正在运行的进程的状态,然后休眠一秒钟,直到进程自行退出。这确保安装程序确实可以执行其想要执行的操作。

相关内容