• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

251
Views
Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed

I am creating application which stop the IIS Default Web Site. I used a PowerShell script to stop website because that script is executed form my website.

This is my script:

Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\WebAdministration
Stop-Website 'Default Web Site'
my copy code
Start-Website 'Default Web Site'

And this is my C# code:

PowerShell _PowerShell = PowerShell.Create();

Runspace rs = RunspaceFactory.CreateRunspace();
rs.Open();

_PowerShell.Runspace = rs;
_PowerShell.AddScript(@"Set-ExecutionPolicy RemoteSigned -scope LocalMachine").Invoke();
_PowerShell.AddScript(@"E:\DE.TEST\Power_Shell\Scripts\StopIISDefaultSite.ps1").Invoke();

if (_PowerShell.HadErrors)
{
    Collection<ErrorRecord> errors = _PowerShell.Streams.Error.ReadAll();

    foreach (var item in errors)
    {
        Console.WriteLine(item.ToString());
    }
}

Console.ReadLine();

It shows the following error

Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

about 3 years ago · Santiago Trujillo
2 answers
Answer question

0

You need to check whether the PowerShell instance you are running your PS code under is 32-bit or 64-bit and make your solution build for that target platform. You can check this using:

if([IntPtr]::size -eq 8) { Write-Host 'x64' } else { Write-Host 'x86' }

Source

As pointed out in the comments setion, if you are running PowerShell 64-bit, building your solution for AnyCPU and unchecking "Prefer 32-bit" solves the issue.

about 3 years ago · Santiago Trujillo Report

0

Following on from @Jenish Zinzuvadiya's answer regarding PowerShell running as x86/x64, in my case the problem was that I was launching PowerShell from Visual Studio by using the "Open Command Line" plugin, which was launching PowerShell as an x86 process.

Launching PowerShell from the Start Menu did so as an x64 process and that resolved the problem for me.

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error