1

我有一个 PowerShell 脚本,如果手动执行它可以正常工作,但是当我尝试通过在 InstallShield 2015 中创建一个函数来执行它时,它会失败并出现以下错误 -

get-webconfiguration:检索具有 CLSID 80040154 类未注册的组件的 COM 类工厂 {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} 由于以下错误而失败:80040154 未注册类(来自 HRESULT 的异常:0X80040154(REGDB_E_CLASSNOTREG))

下面是安装过程中调用的 InstallShield 函数,用于更新 IIS 中虚拟应用程序的物理路径。

function VirtualAppPowershell()

    STRING szMsg, szCmdLine, szAppPath1, szDir;
    NUMBER nResult;
    STRING szFile, svDir;

begin                               

    try
        szAppPath1 = "powershell.exe";
        //szAppPath1 = "powershell_ise.exe";

        szDir = TARGETDIR;

        svDir = TARGETDIR + "Demo\\Script\\";
        szCmdLine = "-File .\\VirtualAppPathChange.ps1 \"" + svDir +"\\\""; 


        StrRemoveLastSlash (svDir);

        ChangeDirectory(svDir);

        szMsg = "Updating PhysicalPath of Virtual application";                                    

        SdShowMsg ( szMsg , TRUE );
        Delay (5);       
        nResult = LaunchAppAndWait (szAppPath1, szCmdLine, WAIT|LAAW_OPTION_MINIMIZED);
        SdShowMsg ( szMsg , FALSE );  

    catch
        WriteLogAsError(FALSE, Err.Number, Err.Description);
        Err.Raise();
    endcatch;

    return nResult;
end;  

这是 PowerShell 脚本的代码以及供参考-

#Code to get PhysicalPath of Virtual application
$WebClientPath=(get-webapplication DemoApp).PhysicalPath

# Code to get Installation Directory path
$CommonNode=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Demo\Platform\Common
$InstallationDir=$CommonNode.InstallationDir

#Appended new foldername to $Path1
$Path1= $InstallationDir + "Test\"

#Appended old foldername to $Path2
$Path2= $InstallationDir + "Dem\"


# Code to get Version of application
$PlatformNode=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Demo\Platform
$Version=$PlatformNode.VERSION

if($Version -ge "7.3.0.0")
{
    Set-ItemProperty 'IIS:\Sites\Default Web Site\DemoApp' -Name physicalPath -Value "$Path1"
}
else
{
    Set-ItemProperty 'IIS:\Sites\Default Web Site\DemoApp' -Name physicalPath -Value "$Path2"
}

注意 -我的操作系统是 64 位的。

4

0 回答 0