我正在使用启动脚本来部署 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);
好吧,我发现了问题。安装可执行文件在执行任何操作之前就被 Windows 终止了,这让事情变得非常混乱。看起来安装程序只是没有正确地完成它的工作。
似乎安装可执行文件被异步调用,Windows 没有等待它完成就继续启动过程。下面的代码似乎解决了这个问题:
我在调用安装程序可执行文件后直接添加了这个循环。它检查正在运行的进程的状态,然后休眠一秒钟,直到进程自行退出。这确保了安装程序实际上可以做它想做的事。