I have a PowerShell script which works fine if executed manually but when i try to execute it by creating a function in InstallShield 2015, it fails with below error -
get-webconfiguration : Retrieving COM class factory for component with CLSID 80040154 class not registered {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} FAILED DUE TO THE FOLLOWING ERROR : 80040154 Class not registered (Exception from HRESULT: 0X80040154 (REGDB_E_CLASSNOTREG))
Below is the InstallShield function which is called during installation to update the Physical path of the Virtual application in 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;
Here is the code of PowerShell Script as well for reference-
#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"
}
Note - My OS is 64 bit.
User contributions licensed under CC BY-SA 3.0