我有一个PowerShell脚本,如果手动执行该脚本可以正常工作,但是当我尝试通过在InstallShield 2015中创建一个函数来执行该脚本时,它将失败并显示以下错误-
get-webconfiguration:使用以下内容检索组件的COM类工厂 CLSID 80040154类未注册 {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位。