Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

cannot create cab file

$
0
0

I got this error when creating cab file following the script below:

New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due 

to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

At line:11 char:9

+     $cab = New-Object -ComObject $makecab

+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException

    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

 

unable to create makecab.makecab object

At line:12 char:14

+     if(!$?) { $(Throw "unable to create $makecab object")}

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (unable to create makecab.makecab object:String) [], RuntimeException

    + FullyQualifiedErrorId : unable to create makecab.makecab object

 ____________________________________________________________________

 

Param(

$filepath = "C:\fso",

$path = "C:\fso\aCab.cab",

[switch]$debug

)

Function New-Cab($path,$files)

{

$makecab = "makecab.makecab"

Write-Debug "Creating Cab path is: $path"

$cab = New-Object -ComObject $makecab

if(!$?) { $(Throw "unable to create $makecab object")}

$cab.CreateCab($path,$false,$false,$false)

ForEach ($file in $files)

{

$file = $file.fullname.tostring()

$fileName = Split-Path -path $file -leaf

Write-Debug "Adding from $file"

Write-Debug "File name is $fileName"

$cab.AddFile($file,$filename)

}

Write-Debug "Closing cab $path"

$cab.CloseCab()

} #end New-Cab

# *** entry point to script ***

if($debug) {$DebugPreference = "continue"}

$files = Get-ChildItem -path $filePath | Where-Object { !$_.psiscontainer }

New-Cab -path $path -files $files.





Viewing all articles
Browse latest Browse all 6937

Trending Articles