void CmdComponent::Exec()
{
	std::wstring l_command;
	
	switch(InstallerSession::Instance->sequence)
	{
	case SequenceInstall:
		l_command = InstallUILevelSetting::Instance->GetCommand(
			command, command_basic, command_silent);
		break;
	case SequenceUninstall:
		l_command = InstallUILevelSetting::Instance->GetCommand(
			uninstall_command, uninstall_command_basic, uninstall_command_silent);
		break;
	default:
		THROW_EX(L"Unsupported install sequence: " << InstallerSession::Instance->sequence << L".");
	}
	
	std::wstring additional_cmd = GetAdditionalCmd();
	if (! additional_cmd.empty())
    {
		l_command.append(L" ");
		l_command.append(additional_cmd);
    }

	l_command = InstallerSession::Instance->ExpandUserVariables(l_command);

	LOG(L"Executing: " << l_command);

	ProcessComponent::ExecCmd(l_command, execution_method, disable_wow64_fs_redirection);
};
Esempio n. 2
0
std::wstring MsiComponent::GetCommandLine() const
{
	std::wstring l_command = L"msiexec";
	std::wstring l_package;
	std::wstring l_cmdparameters;	

	switch(InstallerSession::Instance->sequence)
	{
	case SequenceInstall:
		l_package = package.GetValue();
		l_cmdparameters = InstallUILevelSetting::Instance->GetCommand(
			cmdparameters, cmdparameters_basic, cmdparameters_silent);
		l_command += L" /i"; 
		break;
	case SequenceUninstall:
		l_package = uninstall_package.empty() 
			? package.GetValue()
			: uninstall_package.GetValue();
		l_cmdparameters = InstallUILevelSetting::Instance->GetCommand(
			uninstall_cmdparameters, uninstall_cmdparameters_basic, uninstall_cmdparameters_silent);
		l_command += L" /x"; 
		break;
	default:
		THROW_EX(L"Unsupported install sequence: " << InstallerSession::Instance->sequence << L".");
	}

	l_command.append(L" ");
	l_command.append(DVLib::GetQuotedPathOrGuid(l_package));

	LOG(L"-- Package: " << l_package);

	if (! l_cmdparameters.empty())
	{
		LOG(L"-- Additional command-line parameters: " << l_cmdparameters);
		l_command.append(L" ");
		l_command.append(l_cmdparameters);
	}
	
	std::wstring additional_cmd = GetAdditionalCmd();
	if (! additional_cmd.empty())
    {
		l_command.append(L" ");
		l_command.append(additional_cmd);
    }

	l_command = InstallerSession::Instance->ExpandUserVariables(l_command);

	return l_command;
}
Esempio n. 3
0
void MsuComponent::Exec()
{
	std::wstring l_command = L"wusa.exe ";

	switch(InstallerSession::Instance->sequence)
	{
	case SequenceInstall:
		break;
	default:
		THROW_EX(L"Unsupported install sequence: " << InstallerSession::Instance->sequence << L".");
	}

	l_command.append(L"\"");
	l_command += DVLib::DirectoryCombine(DVLib::GetCurrentDirectoryW(), package);
	l_command.append(L"\"");

	std::wstring l_cmdparameters = InstallUILevelSetting::Instance->GetCommand(
		cmdparameters, cmdparameters_basic, cmdparameters_silent);
	
	if (! l_cmdparameters.empty())
	{
		LOG(L"-- Additional command-line parameters: " << l_cmdparameters);
		l_command.append(L" ");
		l_command.append(l_cmdparameters);
	}
	
	std::wstring additional_cmd = GetAdditionalCmd();
	if (! additional_cmd.empty())
    {
		l_command.append(L" ");
		l_command.append(additional_cmd);
    }

	l_command = InstallerSession::Instance->ExpandUserVariables(l_command);

    LOG(L"Executing: " << l_command);

	if (disable_wow64_fs_redirection)
	{
		auto_any<Wow64NativeFS *, close_delete> wow64_native_fs(new Wow64NativeFS());
		DVLib::RunCmd(l_command, & m_process_info);
	}
	else
	{
		DVLib::RunCmd(l_command, & m_process_info);
	}
}
void ExeComponent::Exec()
{
    std::wstring l_command;
    std::wstring l_exeparameters;
    std::wstring l_responsefile_source;
    std::wstring l_responsefile_target;

    // make executable executable
    switch(InstallerSession::Instance->sequence)
    {
    case SequenceInstall:
        l_command = InstallUILevelSetting::Instance->GetCommand(
                        executable, executable_basic, executable_silent);
        l_exeparameters = InstallUILevelSetting::Instance->GetCommand(
                              exeparameters, exeparameters_basic, exeparameters_silent);
        l_responsefile_source = responsefile_source;
        l_responsefile_target = responsefile_target;
        break;
    case SequenceUninstall:
        l_command = InstallUILevelSetting::Instance->GetCommand(
                        uninstall_executable, uninstall_executable_basic, uninstall_executable_silent);
        l_exeparameters = InstallUILevelSetting::Instance->GetCommand(
                              uninstall_exeparameters, uninstall_exeparameters_basic, uninstall_exeparameters_silent);
        l_responsefile_source = uninstall_responsefile_source;
        l_responsefile_target = uninstall_responsefile_target;
        break;
    default:
        THROW_EX(L"Unsupported install sequence: " << InstallerSession::Instance->sequence << L".");
    }

    LOG(L"-- Executable: " << l_command);

    // install_dir
    std::wstring installdir = InstallerSession::Instance->ExpandUserVariables(install_directory.GetValue());
    if (InstallerSession::Instance->sequence == SequenceInstall && ! installdir.empty())
    {
        bool installdir_exists = DVLib::DirectoryExists(installdir);
        if (! installdir_exists)
        {
            LOG(L"-- Creating install_directory directory '" << installdir << L"'");
            DVLib::DirectoryCreate(installdir);
        }
        else
        {
            LOG(L"-- Directory '" << installdir << L"' exists");
        }
    }

    // response file
    if (! l_responsefile_source.empty() && ! l_responsefile_target.empty())
    {
        LOG(L"-- Response file source: " << l_responsefile_source << L" (" << responsefile_format << L")");
        LOG(L"-- Response file target: " << l_responsefile_target);
        ResponseFilePtr r;
        ResponseFileFormat l_responsefile_format = ResponseFile::string2responsefileformat(responsefile_format);
        switch(l_responsefile_format)
        {
        case ResponseFileFormatNone:
            reset(r, new ResponseFileNone(l_responsefile_source, l_responsefile_target));
            break;
        case ResponseFileFormatIni:
            reset(r, new ResponseFileIni(l_responsefile_source, l_responsefile_target));
            break;
        case ResponseFileFormatText:
            reset(r, new ResponseFileText(l_responsefile_source, l_responsefile_target));
            break;
        default:
            THROW_EX(L"Unsupported response file format: " << responsefile_format);
        }

        r->Exec();
    }

    if (! l_exeparameters.empty())
    {
        LOG(L"-- Additional command-line parameters: " << l_exeparameters);
        l_command.append(L" ");
        l_command.append(l_exeparameters);
    }

    std::wstring additional_cmd = GetAdditionalCmd();
    if (! additional_cmd.empty())
    {
        l_command.append(L" ");
        l_command.append(additional_cmd);
    }

    l_command = InstallerSession::Instance->ExpandUserVariables(l_command);

    LOG(L"Executing: " << l_command);

    CHECK_BOOL(! l_command.empty(), L"Component command is empty");

    ProcessComponent::ExecCmd(l_command, execution_method, disable_wow64_fs_redirection);
};
Esempio n. 5
0
std::wstring MspComponent::GetCommandLine() const
{
	std::wstring l_command = L"msiexec";
	std::wstring l_cmdparameters;

	switch(InstallerSession::Instance->sequence)
	{
	case SequenceInstall:
		// patch
		l_command += L" /p ";
		l_command += DVLib::GetQuotedPathOrGuid(patch.GetValue());
		// apply a patch to an administrative package
		if (! package.GetValue().empty())
		{
			l_command += L" /a ";
			l_command += DVLib::GetQuotedPathOrGuid(package.GetValue());
		}
		// command-line parameters		
		l_cmdparameters = InstallUILevelSetting::Instance->GetCommand(
			cmdparameters, cmdparameters_basic, cmdparameters_silent);
		// REINSTALL
		if (! reinstall.GetValue().empty()) 
		{
			l_cmdparameters += L" REINSTALL=";
			l_cmdparameters += reinstall.GetValue();
		}
		// REINSTALLMODE
		if (! reinstallmode.GetValue().empty())
		{
			l_cmdparameters += L" REINSTALLMODE=";
			l_cmdparameters += reinstallmode.GetValue();
		}
		break;
	case SequenceUninstall:
		// command-line parameters
		l_cmdparameters = InstallUILevelSetting::Instance->GetCommand(
			uninstall_cmdparameters, uninstall_cmdparameters_basic, uninstall_cmdparameters_silent);
		// command
		l_command += L" /uninstall ";
		// patch
		l_command.append(DVLib::GetQuotedPathOrGuid(uninstall_patch.GetValue().empty() ?
			patch : uninstall_patch));
		// msi affected
		if (! uninstall_package.GetValue().empty())
		{
			l_command += L" /package ";
			l_command.append(DVLib::GetQuotedPathOrGuid(uninstall_package));
		}
		break;
	default:
		THROW_EX(L"Unsupported install sequence: " << InstallerSession::Instance->sequence << L".");
	}

	if (! l_cmdparameters.empty())
	{
		l_command.append(L" ");
		l_command.append(l_cmdparameters);
	}
	
	std::wstring additional_cmd = GetAdditionalCmd();
	if (! additional_cmd.empty())
    {
		l_command.append(L" ");
		l_command.append(additional_cmd);
    }

	l_command = InstallerSession::Instance->ExpandUserVariables(l_command);
	return l_command;
}