Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl - Win32::OLE::const error

I’m trying to use WinSCP for SFTP with a Perl script. I’m pretty much using the code off of the WinSCP site verbatim. But I’m getting the following error:

Win32::OLE::CONST->Load: No or invalid type library name at test.pl line 12. Win32::OLE(0.1712): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/lib/Win32/OLE/Const.pm line 49.

Does anyone know what could be causing this?

My code:

use Win32::OLE;
use Win32::OLE::Const;
use Win32::OLE::Variant;
 
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
my $session = Win32::OLE->new('WinSCP.Session');
 
my $consts = Win32::OLE::Const->Load($session);
 
my $sessionOptions = Win32::OLE->new('WinSCP.SessionOptions');
like image 216
Cory Kleiser Avatar asked Jun 21 '26 17:06

Cory Kleiser


1 Answers

Make sure you have registered WinSCP .NET assembly for COM:

%WINDIR%\Microsoft.NET\Framework\<version>\RegAsm.exe WinSCPnet.dll /codebase /tlb
like image 193
Martin Prikryl Avatar answered Jun 23 '26 10:06

Martin Prikryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!